https://github.com/luvies/mapped-replace
Performs a replacement on a string using a map
https://github.com/luvies/mapped-replace
javascript map mapped node node-js nodejs object replace string typescript
Last synced: 2 months ago
JSON representation
Performs a replacement on a string using a map
- Host: GitHub
- URL: https://github.com/luvies/mapped-replace
- Owner: luvies
- License: mit
- Created: 2018-09-18T20:18:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-19T22:23:52.000Z (over 7 years ago)
- Last Synced: 2024-10-16T08:33:01.340Z (over 1 year ago)
- Topics: javascript, map, mapped, node, node-js, nodejs, object, replace, string, typescript
- Language: TypeScript
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mapped Replace
 [](https://coveralls.io/github/luvies/mapped-replace?branch=master) [](https://www.npmjs.com/package/mapped-replace)
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
```ts
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'
```