1.0.2 • Published 3 years ago

text-replacer v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Text-Replace [NPM version]

Node.js transform stream that performs text based search and replacements. Since replaceAll method is not defined in nodeJs so I designed this for some usefull use case.

Installation

npm install text-replacer --save

Usage

Streaming search and replace

Let's say we have the following text:

I am here to say you~br~but you don't want to listen

To replace all occurrences of '~br~' with '\' we could do this:

const Replacer = require("replace-text");

let replacerConfig = {
"~br~": "<br />",
"~tb~": "<hr />",
};
let replacer = new Replacer(replacerConfig);

replacer.replace("I am here to say you~br~but you don't want to listen");  //I am here to say you<br />but you don't want to listen