String Replacer
Tiny and fast string replacer utility.
Usage
const strep = great = console
Hello World!
Objects are supported as well:
const format = name = nick: 'Johnny' first: 'John' last: 'Doe' console
John Doe (Johnny)
Custom placeholders
By default the following regexp is employed to find placeholders in a format string: /{([a-zA-Z0-9_]+)}/g
You are able to override it globally or per call to use different placeholders.
streppattern = /\{{\s*\s*}}/g // override globally const mustache = bash = // override just for this call consoleconsole
Buggy is my cat.Hello Buggy!
Note: mind the capturing group in those regexps. Those are required to work properly.
Installation
With npm:
npm install strep
Tests & benchmarks
Run unit tests:
npm test
Run unit tests and create coverage report:
npm run cover
Run benchmark:
npm run benchmark