1.4.1 • Published 7 years ago
@cjssdk/format v1.4.1
String substitution according to the given format
Simplified speed-oriented JavaScript equivalent of the C/PHP sprintf function.
Installation
npm install @cjssdk/formatUsage
Add to the scope:
var format = require('@cjssdk/format');Simple replacement:
// This is a cat
console.log(format('This is a {0}', 'cat'));Multiple replacement:
// This is a cat and a dog
console.log(format('This is a {0} and a {1}', 'cat', 'dog'));Replacement with changed order:
// This is a cat and a dog and another cat
console.log(format('This is a {0} and a {1} and another {0}', 'cat', 'dog'));Development mode
There is a global var
DEVELOPwhich activates additional consistency checks and protection logic not available in release mode.
Contribution
If you have any problems or suggestions please open an issue according to the contribution rules.
License
@cjssdk/format is released under the MIT License.
1.4.1
7 years ago