Node plugin for string formatting with dynamic values like python
npm install strmat
or
yarn add strmat
const Strmat = require('strmat');
const string = 'This will {0} using dynamic {1}';
const values = ['format', 'queries'];
const formattedString = Strmat.format(string, values);
// Output:
// This will format using dyamic queries
const string = 'This will {firstKey} using dynamic {secondKey}';
const values = {
'firstKey': 'format',
'secondKey': 'queries'
};
const formattedString = Strmat.format(string, values);
// Output:
// This will format using dyamic queries
const string = 'This will not use dynamic values';
const values = {};
const formattedString = Strmat.format(string, values);
// Output
// This will not use dynamic values
const string = 'This will not use dynamic values';
const values = [];
const formattedString = Strmat.format(string, values);
// Output
// This will not use dynamic values
const string = undefined;
const values = ['format'];
const formattedString = Strmat.format(string, values);
// Output
// undefined
Interested in contributing to this project? You can log any issues or suggestion related to this library here.
Read our contributing guide to get started with contributing to the codebase.