{"name":"replacements","description":"Transform a string with an array of replacement patterns.","version":"0.2.0","homepage":"https://github.com/jonschlinkert/replacements","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/replacements.git"},"bugs":{"url":"https://github.com/jonschlinkert/replacements/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/replacements/blob/master/LICENSE"},"files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"*","should":"^5.2.0"},"keywords":["regex","regular expression","escape","expression","match","modify","pattern","replace","replacement","search","structure","substitute"],"gitHead":"547844fdeaad0104df77dea22111236de1eac354","_id":"replacements@0.2.0","_shasum":"854b539a312fe8d8b0120b9e95e712eb44cce24e","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"854b539a312fe8d8b0120b9e95e712eb44cce24e","tarball":"http://registry-npm.ywwl.com/replacements/download/replacements-0.2.0.tgz","integrity":"sha512-tg2Il6p3wg8xMzLfS6NqrrSOc1k34xcqD40Mf1zfBXgXG9Z71kcHiOuaPBXRmPmIP4XcbylUJ/sJ54co8N0+Ig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNEJJP6SKMHBfMQmlPBY+TkVgXjMw9eG8RXz358dW5MgIgEtLT7n/eqoIvnrMPvluO+6kSDx9Da17l4pc6g5LDH7w="}],"size":2190,"noattachment":false,"key":"/replacements/-/replacements-0.2.0.tgz"},"directories":{},"readme":"# replacements [![NPM version](https://img.shields.io/npm/v/replacements.svg)](https://www.npmjs.com/package/replacements) [![Build Status](https://img.shields.io/travis/jonschlinkert/replacements.svg)](https://travis-ci.org/jonschlinkert/replacements)\n\n> Transform a string with an array of replacement patterns.\n\n- [Install](#install)\n- [Usage](#usage)\n  * [object of replacement patterns](#object-of-replacement-patterns)\n  * [key-value replacement patterns](#key-value-replacement-patterns)\n  * [array of replacement patterns](#array-of-replacement-patterns)\n  * [functions as replacements](#functions-as-replacements)\n- [Related projects](#related-projects)\n- [Running tests](#running-tests)\n- [Contributing](#contributing)\n- [Author](#author)\n- [License](#license)\n\n_(TOC generated by [verb](https://github.com/verbose/verb))_\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i replacements --save\n```\n\n## Usage\n\n```js\nvar replace = require('replacements');\n```\n\n### object of replacement patterns\n\n```js\nvar transformers = {\n  pattern: /a/g,\n  replacement: 'bbb'\n};\nconsole.log(replace('aaa', transformers));\n//=> 'bbbbbbbbb'\n```\n\n### key-value replacement patterns\n\nFor basic string transformations, you can pass the string to replace as the key, and the replacement as a value:\n\n```js\nvar transformers = {\n  'a': 'b'\n  'c': 'd'\n};\nconsole.log(replace('aaabbbccc', transformers));\n//=> 'bbbbbbddd'\n```\n\n_Note that only the first matching string will only be replaced using this format. If you need more flexibility, use the pattern-replacement regex syntax._.\n\n### array of replacement patterns\n\n```js\nvar transformers = [\n  {pattern: /a/g, replacement: 'bbb'},\n  {pattern: /b/g, replacement: 'ccc'},\n  {pattern: /c/g, replacement: 'ddd'},\n  {pattern: /d/g, replacement: 'eee'},\n  {pattern: /[e]+/g, replacement: '_DONE_'}\n];\nconsole.log(replace('aaa', transformers));\n//=> '__DONE__'\n```\n\n### functions as replacements\n\n```js\nvar transformers = {\n  pattern: /a+/g,\n  replacement: function(match) {\n    return match.split('').map(function(str, i) {\n      if (i === 0) {return 'b'; }\n      if (i === 1) {return str.toUpperCase();}\n      return str;\n    }).join('');\n  }\n};\nconsole.log(replace('aaa', transformers));\n//=> 'bAa'\n```\n\n## Related projects\n\n[easy-renamer](https://www.npmjs.com/package/easy-renamer): Easily rename files using custom rename functions that are automatically used against any filepaths that… [more](https://www.npmjs.com/package/easy-renamer) | [homepage](https://github.com/jonschlinkert/easy-renamer)\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d && npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/replacements/issues/new).\n\n## Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb) on December 20, 2015._","publish_time":1426252044133,"_cnpm_publish_time":1426252044133,"dist-tags":{"latest":"0.2.1"}}