1.0.0 • Published 4 months ago

replacemany v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 months ago

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.