@jrbailey819/unique-string-interpolator
v1.0.3
Published
A lightweight package for formatting strings with parameter interpolation
Downloads
3
Maintainers
Readme
String Formatter
A simple and lightweight Node.js package for formatting strings with parameter interpolation.
Installation
npm install string-formatter
Usage
const StringFormatter = require('string-formatter');
const formatter = new StringFormatter();
const template = 'Hello, ${name}! You are ${age} years old.';
const params = { name: 'John', age: 30 };
const result = formatter.format(template, params);
console.log(result); // Output: Hello, John! You are 30 years old.
API
StringFormatter
The main class exported by this package.
format(template: string, params: object): string
Formats the given template string by replacing placeholders with corresponding values from the params object.
template
: A string containing placeholders in the format${key}
.params
: An object containing key-value pairs for interpolation.
Returns the formatted string.
License
MIT