{"_id":"stream-replace-string","_rev":"5-44a09e1519bf72b51c5c60152f617196","name":"stream-replace-string","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"stream-replace-string","version":"1.0.0","description":"Replaces strings in a stream.","main":"./dist/cjs/index.cjs","types":"./index.d.ts","type":"module","exports":{".":{"import":"./index.js","require":"./dist/cjs/index.cjs"},"./":"./"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ChocolateLoverRaj/stream-replace-string.git"},"keywords":["string","replace","find","find-and-replace","stream","transform"],"author":{"name":"Rajas Paranjpe"},"license":"MIT","bugs":{"url":"https://github.com/ChocolateLoverRaj/stream-replace-string/issues"},"homepage":"https://github.com/ChocolateLoverRaj/stream-replace-string#readme","gitHead":"b1b5f235480f9acc93cbd53b3c93b4fe68e07776","_id":"stream-replace-string@1.0.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.8","dist":{"integrity":"sha512-HnPOXKQE5FijiDYU6SeSs2bfsTCXAGDkVMfSTIRAlMKOXgfcV+WG5RcO8uCouGM1o7R55YManLxWpBcoGtXRNQ==","shasum":"30294c32db5b3a7e280a0b63d26b3305607ff42f","tarball":"https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-1.0.0.tgz","fileCount":6,"unpackedSize":18272,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfY9QjCRA9TVsSAnZWagAAmjAP/i2hx6fqkkJoPsAR2cEi\nkRIYYXGDJVfKEFGD3MEwbSVhUmusy2g0UyhqHsP1vm4ve2pQrzw3CW/Xz6de\nfNliKXp9vJStUPN0IrN+i+9Oqle3tHqx3HGUFX8Cnc/LOdvuR+GU7CHHi3Od\nj3zlR9K2lomQi5pks5oUW4RFkqqdyj6hgdgYivq9onVa/kUn20YNvFQhofFm\nIu4Uy9tCkBT9xETqf9vm+6VTRqmPl65UwM4Y6Cl1BidavgeNZpJr+BvJHQ7L\nvqcWr9o6YtYIqJSrd6iPG6GKvVR1R3BsAEc+qY0fEVNzPJxlIgHmckw31h2n\ny0GLn4JkZASS5twssm+Y2W+UGK7NMD0pUCzMQPA2coRYlOCW2Ky8C73Rt2zk\nI2aI5O2diqfm8tSWRUTgwaYZ6u8/xftw1rZtNdMzwmHs7Er8gaiIhBXtIWNK\nwlImK/XrteAeFoyNnlCx4sBLCKRj8JPYyCZIy5YxKltsQbw+Q2tVUe7RpYZS\nnRA+jMKNajlUc7Z9t9Wr89YXbaqUN8D+vAXdU2txiY05IGA9gJULdCXrtDFm\nbd8EonxD9+BlIs4ZQkzbpypvuRPQh9NbnXEOZJ7NG9Kq9iEjaQ0ruSNQ385g\nSI6+mLcmm/0gHbx2FoZntI826K0gFC2eiz3AWe4iD5W6rJ3bjRUzqaIF1mYe\njwGM\r\n=razN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGUIfsaC+16WmIXAldEWfR75tIsIb0gu68C1B6GDr7dZAiBHrYKxsvBWYXytjK+oWiIxpgcHgus9u07iAVPURcaIQg=="}]},"maintainers":[{"name":"programmerraj","email":"paranjperajas@gmail.com"}],"_npmUser":{"name":"programmerraj","email":"paranjperajas@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-replace-string_1.0.0_1600377891061_0.6887100172487512"},"_hasShrinkwrap":false},"1.0.1":{"name":"stream-replace-string","version":"1.0.1","description":"Replaces strings in a stream.","main":"./dist/cjs/index.cjs","types":"./index.d.ts","type":"module","exports":{".":{"import":"./index.js","require":"./dist/cjs/index.cjs"},"./":"./"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ChocolateLoverRaj/stream-replace-string.git"},"keywords":["string","replace","find","find-and-replace","stream","transform"],"author":{"name":"Rajas Paranjpe"},"license":"MIT","bugs":{"url":"https://github.com/ChocolateLoverRaj/stream-replace-string/issues"},"homepage":"https://github.com/ChocolateLoverRaj/stream-replace-string#readme","gitHead":"3d165066d85eca8114eb243301fea33aacdfd5a2","_id":"stream-replace-string@1.0.1","_nodeVersion":"12.18.3","_npmVersion":"6.14.8","dist":{"integrity":"sha512-h6lsFez6n9uR90HdGmQxS9gmycQV036wv+1o5pKC3aOEccaKvQQR+Hh6E97jNqxCZ2Y/WBg5N9TrlegtM+kVpA==","shasum":"8142da6222a711d93bcb1462f2dd80f8f3d3620a","tarball":"https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-1.0.1.tgz","fileCount":6,"unpackedSize":18357,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfelUsCRA9TVsSAnZWagAAfGEP/0e7NKqi94eFMWVmWVN9\nFvorYqdwB1h2RdDf0u+yy/ikhDsOSlSPcNJzhrNLU77NArwKGveuf8YXBXtc\nx0xf56c1vNq55LfQKs0fC/9G7kUB+AegUTqwxVDV2JNcAv9yNH/DA2J13lJ6\n89HGsCzCf53J4TLgERr1SR6o+ITAiyzdWSVWFYMevDsEd3Io/Jvbms79D3y2\ne09SgK9OaXKOaMIdfXgNNMqI1HH5u8qmiwwRASXpx5x0/G3NhlpSn6KHNSKP\njOUaUC6OiDYm1ANlz78UNX8zkPLMOD0U+cBQK+llTv7x0gNk5KL95Oqs4ctz\n9mQarPkiW2cpG5ShzoCOgg39yvBSRWUinLYCbt/JQA5Yc+V6/nkBw5BNAWUG\nD1j4xAri9EhJuQIfDhyOU9+UM2RSXfOVl6lEYNyhCZUBQNTd8Gwph4LRq6sE\najmrsDmJhwwjFSLsxgOluEkC7b2quBllZlrdj3wn8u4cSGMgL1Di0zBBqakG\n9GtXkRjpeGFlzMqkxDmCVic4+jxVLdLjff5tmqgrixHhYRITUwKmG5GdU0Ew\nfjEQ0OqrTnaAS6dMbXvKz1UJSNoila8BoGghvrQqGHT+WV6Dyh/e169Y/SW1\nRYNQwdNwHbwUYRXLbglTnNOMmeLQRQX91u8pzlx/j/M55SdxgRWMIako6TEg\n6EbN\r\n=IWNa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAHGnoV0SsOikGWLmuarjwTRXMh7MrH3/I3cehf2NUNFAiEA/9qECD0Uz8qGiSVT/D7ZgfQlpM2qVu1jNl8LRsmG0HA="}]},"maintainers":[{"name":"programmerraj","email":"paranjperajas@gmail.com"}],"_npmUser":{"name":"programmerraj","email":"paranjperajas@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-replace-string_1.0.1_1601852715848_0.5455232603560407"},"_hasShrinkwrap":false},"1.1.0":{"name":"stream-replace-string","version":"1.1.0","description":"Replaces strings in a stream.","main":"./dist/cjs/index.cjs","types":"./index.d.ts","type":"module","exports":{".":{"import":"./index.js","require":"./dist/cjs/index.cjs"},"./":"./"},"scripts":{"lint":"standard"},"repository":{"type":"git","url":"git+https://github.com/ChocolateLoverRaj/stream-replace-string.git"},"keywords":["string","replace","find","find-and-replace","stream","transform"],"author":{"name":"Rajas Paranjpe"},"license":"MIT","bugs":{"url":"https://github.com/ChocolateLoverRaj/stream-replace-string/issues"},"homepage":"https://github.com/ChocolateLoverRaj/stream-replace-string#readme","devDependencies":{"standard":"^14.3.4"},"gitHead":"ea94b51d1347a967edc59deb8a3bb209d531f539","_id":"stream-replace-string@1.1.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.8","dist":{"integrity":"sha512-nGrlTjKijzRE18rthzjq2Yi75MfkShYs/yLNi1o79qZdNsM4aKTk1U3kHfWy/lKF1/2zE5+LPHftjBssZehX5Q==","shasum":"4cf1f652a8620d599c1b8b5c2514139050c46b42","tarball":"https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-1.1.0.tgz","fileCount":8,"unpackedSize":17659,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfemBDCRA9TVsSAnZWagAAnZsP/RRhv0cfqIJ0Dd5ifW4P\nle1FXAA9wonl1QZ7H3FI4FI1e0bc4eyqHmahDPV/scUQNwGnbtd4jKg+XYyf\nKZ0959KLJSiNST/FwEeyt5duryTy00t54MDPRfHFTejwBHgcIgfwkKaNcCsp\n9/BzSEAaojpYsWSxPPkMpO7eTb902PG7dzAeUlKCibEhbmAUycT238+BUbT3\n6UDl6n8aDUegUeid+sPY99xdHz+938rv4neKS9FibghxuF+PP4WhlTF7mapO\nsCgWegWHT38XZiNji2xBVvX2MOV6gdyOyor4dn/Ob8h7Becl/cyh70CAB5Ia\nyYK5C8Is1aWOKQOcnJgSzW7anPkXW7fUb4PWMLIeuJX4g36/PqRHiZ3fMTIE\nsl4izORLrsuCZWENQupbfYyxkkMa4C7fWjWZr3lHaVS511wRxOFsHR30FudH\nNgLtnMDp89Jg5vuAD7gm82ZxOGm4jzjBZXD0AawasCIaFlZ+Hyy5wzMbWspT\nWsbt4zQF8QhT2aVT95qYTAnZoRde+k5PLCZKIamJeSva9ae2eA9bMFEnWW8r\nGWmvAyT6GrkYcaumwLeTNRejn3gyYnCX+MdihtE4ctlfHZaOWamvBlLoo0DA\n1Abt2i1IhySSomONXoppgNX5/etAaR8Z7Huu1m9f1Uv12Zw9WHCGoUQzziIn\n5M2V\r\n=1SJD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBaf5++LfzIlyPu5nJVV9tTE9hWiz6j3HcNp5LghC7ISAiAO7SYroR6PPTsaoU72mNAHId/Js9UeKADgLhdrneNvfQ=="}]},"maintainers":[{"name":"programmerraj","email":"paranjperajas@gmail.com"}],"_npmUser":{"name":"programmerraj","email":"paranjperajas@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-replace-string_1.1.0_1601855555206_0.23368365760535448"},"_hasShrinkwrap":false},"1.1.1":{"name":"stream-replace-string","version":"1.1.1","description":"Replaces strings in a stream.","main":"./dist/cjs/index.cjs","types":"./index.d.ts","type":"module","exports":{".":{"import":"./index.js","require":"./dist/cjs/index.cjs"},"./":"./"},"scripts":{"lint":"standard","test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/ChocolateLoverRaj/stream-replace-string.git"},"keywords":["string","replace","find","find-and-replace","stream","transform"],"author":{"name":"Rajas Paranjpe"},"license":"MIT","bugs":{"url":"https://github.com/ChocolateLoverRaj/stream-replace-string/issues"},"homepage":"https://github.com/ChocolateLoverRaj/stream-replace-string#readme","devDependencies":{"baretest":"^2.0.0","standard":"^17.0.0","stream-to-string":"^1.2.0"},"gitHead":"236f8f3ec88286aa9e9bf846dc9d9ea8e56dd07f","_id":"stream-replace-string@1.1.1","_nodeVersion":"16.19.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-bTyEK8MfJjOq+fVimDwh6g6GKwGFTDvNdM7A1kfr0xtXitUuJGUftCFdlpYm+jiQR+93QifaxEjXi9Cd6rKKTA==","shasum":"801a4d7ba95dbfe3b7eebf84094b27733212c2da","tarball":"https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-1.1.1.tgz","fileCount":8,"unpackedSize":18057,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDdncXfRxT4eXOCJKYdlvIVlGLX2anrp+207oFJMCDWYAiAl4j+/uVn5ge5ZE6x81GoKisJ02A9HPQ2rJ+V+u5Q48g=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjy1DJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq9AxAAkLzb6pXSpkIbCTq2+bz70q58R/mjzXiuO9PqKYpnKhV06yeZ\r\nisDaIiRP1KRTJJJFndgQ3wcIoxmz1OotqHTu0rh4DxIDYNAUL8nl93TipUba\r\nLOO/w2JSyAzf8U7nXj3oelE093PWvqsjlPuiZOxPrkXrZmXA72vkAh6LU3r5\r\nEoMCcsmmJOqEmJ/GfDxNn2pjoAI9EYc+Xnge0PChHVFReEf5Hd/vSS3/Jt6J\r\nDDxaTD7gdSSwrfhJGFberSoeqCu1cfKERngLZQ2abdRdGDnhTEuc0gf8WvL5\r\nChVwvgRZhBGbHgq+6imF0WrK4ozG9vIE20kbDc6RfYAXNyoibcD2iM/NIkmy\r\nK7v2SZmN5ARz7fmphD5/P1MAtnR6H1488xICOQtUgRp0LbdpfNeNHGgtgI4n\r\ncyWKYaVqX9Eo6up7/PZpJGdrm9WM/n1YoytQQv66+ss3tNrsJlQ58Q4JEzEu\r\nA5VnZk7UT3LRUxshK3851sEw/aYG7swNVc1dhWAkQnOvlTGE+zSxcgSH7GFs\r\niU0xfTmST++/lY+58QNqFAg8fecN/w9yaec2Fm5D29UyaxXMHkTsKPdDqoTh\r\nR+xxoBEhNM6sqv8kFQu5FP+GE1Ojk8clNKZMEYPlILKAeN3WuL0ypSxaV4zN\r\nBYOOuzzWykX+Tlj2CSO3kveU0TZe53tmfzw=\r\n=Kaii\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"programmerraj","email":"paranjperajas@gmail.com"},"directories":{},"maintainers":[{"name":"programmerraj","email":"paranjperajas@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-replace-string_1.1.1_1674268873666_0.0066152672903574405"},"_hasShrinkwrap":false},"2.0.0":{"name":"stream-replace-string","version":"2.0.0","description":"Replaces strings in a stream.","main":"./index.js","types":"./index.d.ts","type":"module","scripts":{"lint":"standard","test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/ChocolateLoverRaj/stream-replace-string.git"},"keywords":["string","replace","find","find-and-replace","stream","transform"],"author":{"name":"Rajas Paranjpe"},"license":"MIT","bugs":{"url":"https://github.com/ChocolateLoverRaj/stream-replace-string/issues"},"homepage":"https://github.com/ChocolateLoverRaj/stream-replace-string#readme","devDependencies":{"baretest":"^2.0.0","standard":"^17.0.0","stream-to-string":"^1.2.0"},"gitHead":"0329cb6e764e974267da63da3dbe829fa3e006fd","_id":"stream-replace-string@2.0.0","_nodeVersion":"20.2.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==","shasum":"e49fd584bd1c633613e010bc73b9db49cb5024ad","tarball":"https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-2.0.0.tgz","fileCount":8,"unpackedSize":17000,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHijb2ADxn4ltsRMnjeRJlgD/NlGnKDhvjl4XzaJ8jF2AiBIrcDCVVRpL+XyGjKAj6zUeiLdWVwGr2qVsMDe2Bflow=="}]},"_npmUser":{"name":"programmerraj","email":"paranjperajas@gmail.com"},"directories":{},"maintainers":[{"name":"programmerraj","email":"paranjperajas@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-replace-string_2.0.0_1685135763696_0.1163409300126641"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-17T21:24:51.060Z","1.0.0":"2020-09-17T21:24:51.227Z","modified":"2023-05-26T21:16:03.939Z","1.0.1":"2020-10-04T23:05:15.970Z","1.1.0":"2020-10-04T23:52:35.343Z","1.1.1":"2023-01-21T02:41:13.821Z","2.0.0":"2023-05-26T21:16:03.823Z"},"maintainers":[{"name":"programmerraj","email":"paranjperajas@gmail.com"}],"description":"Replaces strings in a stream.","homepage":"https://github.com/ChocolateLoverRaj/stream-replace-string#readme","keywords":["string","replace","find","find-and-replace","stream","transform"],"repository":{"type":"git","url":"git+https://github.com/ChocolateLoverRaj/stream-replace-string.git"},"author":{"name":"Rajas Paranjpe"},"bugs":{"url":"https://github.com/ChocolateLoverRaj/stream-replace-string/issues"},"license":"MIT","readme":"# stream-replace-string\nReplaces strings in a stream.\n\n## Install\n```shell\nnpm i stream-replace-string\n```\n\n## Using\n```javascript\nimport replace from 'stream-replace-string'\nimport { createReadStream, createWriteStream } from 'fs'\n\ncreateReadStream(\"./input.txt\")\n    .pipe(replace(\"{fruit}\", \"apple\"))\n    .pipe(createWriteStream(\"./output.txt\"))\n```\nYou can also replace multiple different words by piping your data through multiple replace streams\n```javascript\ncreateReadStream(\"./input.txt\")\n    .pipe(replace(\"good\", \"great\"))\n    .pipe(replace(\"bad\", \"horrible\"))\n    .pipe(replace(\"grey\", \"gray\"))\n    .pipe(createWriteStream(\"./output.txt\"))\n```\n\n### The `replace` function\n```javascript\nreplace(searchStr, replaceWith, options)\n```\n- Parameters\n    - `searchStr` - The string to search for. This must be a string, and cannot be a regex.\n    - `replaceWith` - There are a couple of different things you can use:\n        - String - Inserts the string.\n        - Promise resolving a string - Once the promise is resolved, the given string is used.\n        - Replacer function - This is a custom replacer function. The function can take a parameter, `matches`, which is the number of matches so far (for the first match, this will be `0`). This function should return a string or a promise resolving a string.\n        - Readable stream - A readable stream can be given, which can make more chunks available sooner. See `options.bufferReplaceStream` for options if you are using a readable stream.\n    - `options` (optional) - An object of options.\n        - `limit` (optional, default `Infinity`) - The maximum number of strings to replace. This can be useful if you know there is only 1 occurrence of `searchStr`. Once this limit is reached, the transform stream will stop transforming anything.\n        - `bufferReplaceStream` (optional, default `true`) - This is for when you use a readable stream for `replaceWith`. If this is true, the `replaceWith` stream will be read right away, and be kept in memory to be used once a match is found. For fastest performance, keep this to be `true`. If your `replaceWith` stream is very large and you have a limit of 1, you can set this to `false` to save memory.\n- Returns\n    - Returns a transform stream. See the [How It Works](#how-it-works) section for more information.\n\n## How It Works\n\n### The transform stream\nThe [`replace`](#the-`replace`-function) function returns a Node.js transform stream. Transform streams take in chunks and can also be read. In this particular transform stream, it takes a string and outputs the same string, except that it replaces the replace.\n\n### Efficient memory use.\nThe tricky part with this transform stream is knowing when to hold chunks, and when to pass them on. Let's say we were looking for `'paper'` in our text. If our first chunk was: `'perfect pot'`, this module knows that there is no way the string `'perfect pot'` will fit into the search string, `'paper'`. We can then pass the chunks onto the output of the transform stream, available right away for the stream consumer. However, if our first chunk was: `'p'`, we can't pass that on, because there is a change that the next chunk could start with `'aper'`. Since we aren't sure if the `'p'` will be replaced or not, we hold on to this text, and check it once we get the next chunk. If we get `'aper'` in the next chunk, we replace the text. If we get something else, like `'ear'`, we can attach it to the `'p'` and output `'pear'`. It gets even more complicated when multiple potential matches are possible. Let's say we get `'pap'` in our first chunk. We need to be watching the first `'p'` and the third `'p'`, because it could end up being `'paper'`, if the next chunk was `'er'`, or it could end of being `'papaper'`. This package is smart and it will efficiently find matches spanning multiple chunks, and get rid of text it knows won't have a match.\n\n#### Importing with ESModules\n```javascript\nimport replace from 'stream-replace-string'\n```","readmeFilename":"README.md"}