string-prototype-format-js is a NPM Package 'String.prototype' extension to format a string replacing variables.
# In your terminal, enter command:
npm install string-prototype-format-js
require("string-prototype-format-js");
var str = "Hello I'm % and I'm % years old.";
var formatted = str.format(["John", 24]);
console.log(formatted);
// Output: "Hello I'm John and I'm 24 years old."
"string...".format([...args]: string[], varType?: string): string
Params | Type | Description |
---|---|---|
args |
String[] |
Value of each variable in the same order initiated in the String |
varType |
String |
Where to put each value (Default: $ ) |
If you are interested in this project and want to improve it, fix errors or bugs, you're welcome to contribute.
The MIT License (MIT).
Note
Please see License File for more information.