void-bulk-replace is a tool that let you replace All instances of a text in a string.
npm install void-bulk-replace
const { Replacer, Pair } = require('void-bulk-replace');
// example 1 : using an object
let replacer1 = new Replacer({
'%1': 'Player.',
'%2': '\nType',
'%3': 'Help!'
}).apply('Hello there %1 %2 %3 %1');
console.log(replacer1);
// example 2 : using a pair
let replacer2 = new Replacer(new Pair('%s', 'Hello and Welcome!'));
console.log(replacer2.apply('%s \n%s \n%s \n%s'));
// example 3 : using Replace.of(left, right); instead of using a pair
let replacer3 = Replacer.of('%s', 'Hello and Welcome!');
console.log(replacer3.apply('%s \n%s \n%s \n%s'));