Skip to content

luvies/mapped-replace

Repository files navigation

Mapped Replace

build status Coverage Status npm version

Given a string and an object, will replace all the keys of the object found in the string with the values of the object. TypeScript definitions are shipped with the package.

Examples

mappedReplace('test string', {}) // -> 'test string'

mappedReplace('foo', { 'foo': 'bar' }) // -> 'bar'

mappedReplace('foo bar baz', {
    'foo': 'a',
    'bar': 'b',
    'baz': 'c'
}) // -> 'a b c'

mappedReplace('hello', { 'l': 'w', 'o': 'o uwu' }) // -> 'hewwo uwu'