string-substitute.js

0.0.2 • Public • Published

Substitute

Substitute keys in a string to values of json.

Install

npm i --save substitude

Include

import Substitute from 'substitude'

Initialize

new Substitute();

or

new Substitute(/{([^{]+)}/g, false, true, true);

#params#

regex: regex for replacing, default - /\$([^$ ]+)( |$)/g
inspectObject: flag for parse object, default - true
outUndefined: flag for out undefined, default - false
outNull: flag for out null, default - false

Usages

console.log("My long {first} {second} long {third}".substitute({
    first: {value: 'text'},
    third: null
}, /{([^{]+)}/g));
|
or with custom regex
|
console.log("My long $first $second long $third".substitute({
    first: {a: 'asgsag'},
    third: null
}));``

Package Sidebar

Install

npm i string-substitute.js

Weekly Downloads

2

Version

0.0.2

License

ISC

Unpacked Size

6.43 kB

Total Files

4

Last publish

Collaborators

  • quit...