Socket
Socket
Sign inDemoInstall

string-multiple-replace

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

.github/workflows/nodejs.yml

8

package.json
{
"name": "string-multiple-replace",
"version": "1.0.2",
"version": "1.0.3",
"description": "Replace multiple substrings in a string in turn",
"author": "iChengbo",
"scripts": {
"test": "mocha"
"test": "mocha",
"test-with-coverage": "nyc --reporter=text mocha"
},

@@ -16,3 +17,4 @@ "main": "index.js",

"chai": "^4.3.4",
"mocha": "^9.1.3"
"mocha": "^9.1.3",
"nyc": "^15.1.0"
},

@@ -19,0 +21,0 @@ "keywords": [

# string-multiple-replace
> Replace multiple substrings in a string in turn.
[![LICENSE](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
[![npm-version](https://img.shields.io/npm/v/string-multiple-replace)](https://www.npmjs.com/package/string-multiple-replace)
[![npm](https://img.shields.io/npm/dm/string-multiple-replace.svg)](https://www.npmjs.com/package/string-multiple-replace)

@@ -8,8 +12,16 @@ Replace all substring matches in a string with an mapping object that is table of `replaceThis: withThis`, and you can provide a `sequencer` to decide the order of replacement.

## Install
```sh
npm install --save string-multiple-replace
```
$ npm install --save string-multiple-replace
or
```sh
yarn add string-multiple-replace
```
## Usage
### v1.x.x +
```js

@@ -29,4 +41,4 @@ const multiReplace = require('string-multiple-replace');

### v0.x.x
- Example-1
```js

@@ -41,3 +53,3 @@ const multiReplace = require('string-multiple-replace');

const sequencer = ["brave", "trouble"];
multiReplace(input, matcherObj, true, sequencer);
multiReplace(input, matcherObj, sequencer);
//I'm only cowardly when I have to be. Being cowardly doesn't mean you go looking for escape.

@@ -48,2 +60,3 @@

- Example-2
```js

@@ -58,3 +71,3 @@ const multiReplace = require('string-multiple-replace');

multiReplace(input, matcherObj, true, keys => keys);
multiReplace(input, matcherObj, keys => keys);
//I'm only cowardly when I have to be. Being cowardly doesn't mean you go looking for escape.

@@ -64,19 +77,4 @@

- Example-3
```js
const multiReplace = require('string-multiple-replace');
## API
const input = "abcd, abcd";
const matcherObj = {
"a": "b",
"b": "a"
}
multiReplace(input, matcherObj, false, Object.keys(matcherObj));
//bacd, bacd
```
## API
### v1.x.x
> multiReplace(input, matcherObj[,sequencer])

@@ -86,8 +84,2 @@

### v0.x.x
> multiReplace(input, matcherObj, [needCover,] sequencer)
The original string is replaced in turn according to the `matcherObj`, where `sequencer` determines the replacement order, and `needCover` determines whether to replace the last replacement data in the execution.
#### input

@@ -106,10 +98,2 @@

#### needCover: `discarded`
Type: `boolean`
*Default: false*
A boolean determines whether to overwritten the replacement data in the execution.
> Discarded Instruction: Remove redundant parameters,The existence state of `sequencer`determines the replacement method.
#### sequencer

@@ -116,0 +100,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc