@gocom/tr
v0.1.1
Published
Search and replace substrings in a string haystack
Downloads
10
Readme
Changelog
Search-and-replaces in a string haystack. This is an implementation of the pseudo-standard string translate replacement function found in other languages, which avoids recursively re-replacing the found matches in the already replaced values. This is achieved by moving pointer forward when a found needle value is replaced with the wanted to value, which then avoid erroneously searching for needles from the already replaced to value. Written in TypeScript, and supports both client-side web browser and Node.js backend usage.
⚡ Install
Using npm:
$ npm install @gocom/tr📖 Documentation
See API Docs.
📝 Example Usage
Replace substrings
The following would replace the original red substring with blue and blue with red:
import {tr} from '@gocom/tr';
const result = tr(
'blue, red, yellow',
{
'red': 'blue',
'blue': 'red',
}
);The above result variable would become:
red, blue, yellowFor more see documentation.
🚀 Changes in 0.1.1
- Re-packaged 0.1.0, with URL links corrected in packaged README.md, and release notes.
For changes in previous versions, see CHANGELOG.md.
