JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 848
  • Score
    100M100P100Q95306F

Run multiple regex or string find-and-replace transformations on a string in sequence, reducing the final string to the accumulated result of each transformation.

Package Exports

  • replacements

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (replacements) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

replacements NPM version

Run multiple regex or string find-and-replace transformations on a string in sequence, reducing the final string to the accumulated result of each transformation.

Install

npm

npm i replacements --save

Usage

var replace = require('replacements');

Pass an object of replacement patterns:

var patterns = {
  pattern: /a/g,
  replacement: 'bbb'
};
console.log(replace('aaa', patterns));
//=> 'bbbbbbbbb'

Pass an array of replacement patterns

var patterns = [
  {pattern: /a/g, replacement: 'bbb'},
  {pattern: /b/g, replacement: 'ccc'},
  {pattern: /c/g, replacement: 'ddd'},
  {pattern: /d/g, replacement: 'eee'},
  {pattern: /[e]+/g, replacement: '_DONE_'}
];
console.log(replace('aaa', patterns));
//=> '__DONE__'

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on July 05, 2014.