npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

txtswitch

v0.1.0

Published

在输入的长文本间隔随机插入一个字符

Readme

txtSwitch Usage Guide

中文 | English


**txtSwitch** is an npm package for processing text that can help you randomly insert specific characters between text characters. For example:

A man in his early teens, in the summer, picked up a real gun on the road. Because he was young and ignorant, fearless of heaven and earth, he pulled the trigger. No one died, no one was hurt, he thought it was a blank. Later when he was thirty years old or even older, walking on the road, he heard a faint rustling sound behind him. He stopped and looked back, the bullet hit him right between the eyes. - Lao She

After converting:

**一-个-人-在-十-三-四-岁-的-夏-天-,-在-路-上-捡-到-一-支-真-枪-,-因-为-年-少-无-知-,-天-不-怕-地-不-怕-,-他-扣-下-扳-机-,-没-有-人-死-,-也-没-有-人-受-伤-,-他-认-为-自-己-开-了-空-枪-。-后-来-他-三-十-岁-或-者-更-老-,-走-在-路-上-,-听-到-背-后-有-隐-隐-约-约-的-风-声-,-他-停-下-来-,-回-过-身-去-,-子-弹-正-中-眉-心-。---史-铁-生-**

Here are the steps to install and use **txtSwitch**.

Installation

First, you need to install Node.js and npm on your computer. You can install from the following links:

Then open the terminal or command line window, and install **txtSwitch** through npm:

npm install txtswitch

Usage

After installing **txtSwitch**, you can now use it in your JavaScript code. First, import **txtSwitch** at the top of your file:

import txtSwitch from 'txtSwitch';

Then you can use the txtSwitch function. This function takes two parameters, the first is the text you want to process, and the second is the character you want to insert:

var result = txtSwitch('Hello, world!', 'X'); 

The txtSwitch function will randomly insert 'X' between each character in 'Hello, world!', and return the processed string. So the result variable will contain the processed string.

You can use this result variable, for example print it out:

console.log(result);

txtSwitch Function Parameter Description

Here are the detailed descriptions of the txtSwitch function parameters:

| Parameter | Type | Required | Default | Description | |-|-|-|-|-| | data | String | Required | None | The string to process | | options | Object | Optional | { customStr: '—□■\*\*\*|', repeatTimes: 1} | Custom options including custom string of characters to insert and number of repeats |

Detailed options Object Properties

| Property | Type | Required | Default | Description | |-|-|-|-|-| | customStr | String | Optional | '—□■***|' | Custom characters to insert into data | | repeatTimes | Number | Optional | 1 | Number of times to repeat insertion of characters |

Note: The options parameter is an object that includes customStr and repeatTimes properties. If options is not provided, the function will use default options. If the options object does not have customStr and/or repeatTimes properties, the function will use the defaults for any missing properties.

To use the txtSwitch function, call the function in your code, passing the data and options parameters, as shown in this example:

let options = { customStr: 'X', repeatTimes: 2 };
txtSwitch('Hello, world!', options); 

For more information and usage details on **txtSwitch**, refer to its npm page and GitHub repository.

Translate By https://claude.ai/