@jrbailey819/unique-string-interpolator

1.0.3 • Public • Published

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

/@jrbailey819/unique-string-interpolator/

    Package Sidebar

    Install

    npm i @jrbailey819/unique-string-interpolator

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    2.94 kB

    Total Files

    4

    Last publish

    Collaborators

    • jrbailey819