Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

replacemany

alexstevovich109Apache-2.01.0.0TypeScript support: included

Replace multiple placeholders in a string using a key-value map.

string, replace, template, text processing, string substitution, batch replace, multiple replace, replace all, string formatting, templating engine, dynamic content, variable replacement, document templating, content injection, text manipulation

readme

ReplaceMany

Replace multiple placeholders in a string using a key-value map.

Install

npm install replacemany

Usage

import replaceMany from 'replacemany';

const content = 'Visit {{project}} @ {{url}}.';
const replacements = {
    '{{project}}': 'replaceMany',
    '{{url}}': 'https://github.com/alexstevovich/replacemany',
};

const result = replaceMany(content, replacements);
console.log(result); // "Visit replaceMany @ https://alexstevovich/replacemany."

API

replaceMany(content, replacements)

Replaces all occurrences of keys in the replacements map with their corresponding values.

Parameters:

  • content: string – The input string containing placeholders.
  • replacements: Record<string, string> – An object mapping keys to their replacement values.

Returns:

  • string – A new string with all replacements applied.

Development Homepage:

https://github.com/alexstevovich/replacemany

This link might become replacemany-node in the future if conflicts arise.

License

Licensed under the Apache License 2.0.