{"name":"streamfilter","version":"2.0.0","description":"Filtering streams.","main":"src/index.js","metapak":{"configs":["readme","jsdocs","eslint","mocha","codeclimate","travis"],"data":{"files":"src/*.js tests/*.mocha.js","testsFiles":"tests/*.mocha.js"}},"scripts":{"changelog":"conventional-changelog -p angular -i CHANGELOG.md -s","cli":"env NODE_ENV=${NODE_ENV:-cli}","cover":"istanbul cover _mocha --report html -- tests/*.mocha.js -R spec -t 5000","coveralls":"istanbul cover _mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage","cz":"env NODE_ENV=${NODE_ENV:-cli} git cz","doc":"mkdir -p .readme; echo \"# API\" > .readme/API.md; jsdoc2md src/*.js tests/*.mocha.js >> .readme/API.md","lint":"eslint src/*.js tests/*.mocha.js","metapak":"metapak","mocha":"mocha tests/*.mocha.js","prettier":"prettier --write src/*.js tests/*.mocha.js","preversion":"npm t && npm run lint && npm run metapak -s","test":"npm run mocha","version":"npm run changelog && git add CHANGELOG.md"},"repository":{"type":"git","url":"git+ssh://git@github.com/nfroidure/streamfilter.git"},"keywords":["assert","deepEqual","neat"],"author":{"name":"Nicolas Froidure"},"license":"MIT","bugs":{"url":"https://github.com/nfroidure/streamfilter/issues"},"homepage":"https://github.com/nfroidure/streamfilter","devDependencies":{"commitizen":"^2.9.6","conventional-changelog-cli":"^1.3.5","coveralls":"^2.13.3","cz-conventional-changelog":"^2.0.0","eslint":"^4.12.1","eslint-plugin-prettier":"^2.3.1","istanbul":"^0.4.5","jsdoc-to-markdown":"^3.0.2","metapak":"^1.0.2","metapak-nfroidure":"^2.0.2","mocha":"^3.5.3","mocha-lcov-reporter":"^1.3.0","prettier":"^1.8.2","streamtest":"^1.2.3"},"dependencies":{"readable-stream":"^2.3.3"},"engines":{"node":">=6.9.5"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"greenkeeper":{"ignore":["commitizen","cz-conventional-changelog","conventional-changelog-cli","jsdoc-to-markdown","eslint","eslint-config-prettier","prettier","mocha","mocha-lcov-reporter","coveralls","istanbul"]},"gitHead":"6a0406877d4d10882d72b9b9759a00599d7d5926","_id":"streamfilter@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"6.10.3","_npmUser":{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},"dist":{"integrity":"sha512-qK7QOpRlaXUU742b5V9XtX8X61Ol8mYpeZJN/j0SEmxtEd+G6QWSv/iFLDae3N67b7MblXPU0DsiNSST9CJQRw==","shasum":"f57f20c57d2e1623d315a593e87e5278cc4d0104","tarball":"http://registry-npm.ywwl.com/streamfilter/download/streamfilter-2.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD20VPBvr2n94YX5W/U2zGdG6UTxYdaD98BDBsxkucavwIhANFdHyovvYT8whsukpGfmPgW6424KCcHYHzp7XQBywJF"}],"size":9830,"noattachment":false,"key":"/streamfilter/-/streamfilter-2.0.0.tgz"},"maintainers":[{"name":"nfroidure","email":"nfroidure@elitwork.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/streamfilter-2.0.0.tgz_1512544890228_0.11984894634224474"},"directories":{},"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# streamfilter\n> Filtering streams.\n\n[![Build status](https://secure.travis-ci.org/nfroidure/streamfilter.svg)](https://travis-ci.org/nfroidure/streamfilter)\n[![Coverage Status](https://coveralls.io/repos/nfroidure/streamfilter/badge.svg?branch=master)](https://coveralls.io/r/nfroidure/streamfilter?branch=master)\n[![NPM version](https://badge.fury.io/js/streamfilter.svg)](https://npmjs.org/package/streamfilter)\n[![Dependency Status](https://david-dm.org/nfroidure/streamfilter.svg)](https://david-dm.org/nfroidure/streamfilter)\n[![devDependency Status](https://david-dm.org/nfroidure/streamfilter/dev-status.svg)](https://david-dm.org/nfroidure/streamfilter#info=devDependencies)\n[![Dependency Status](https://dependencyci.com/github/nfroidure/streamfilter/badge)](https://dependencyci.com/github/nfroidure/streamfilter)\n[![Package Quality](http://npm.packagequality.com/shield/streamfilter.svg)](http://packagequality.com/#?package=streamfilter)\n[![Code Climate](https://codeclimate.com/github/nfroidure/streamfilter.svg)](https://codeclimate.com/github/nfroidure/streamfilter)\n\n\n[//]: # (::contents:start)\n\n`streamfilter` is a function based filter for streams inspired per gulp-filter\n but no limited to Gulp nor to objectMode streams.\n\n## Installation\n\nFirst, install `streamfilter` in your project:\n```sh\nnpm install --save streamfilter\n```\n\n## Getting started\n\nThere are 3 common usages:\n\n### Simple filter\n\n```js\nimport FilterStream from 'streamfilter';\n\nconst filter = new FilterStream((chunk, encoding, cb) => {\n  const mustBeFiltered = chunk.length() > 128;\n  if(mustBeFiltered) {\n    cb(true);\n    return;\n  }\n  cb(false);\n});\n\n// Print to stdout a filtered stdin\nprocess.stdin\n  .pipe(filter)\n  .pipe(process.stdout);\n```\n\n### Filter and restore\n\n```js\nimport FilterStream from 'streamfilter';\n\nconst filter = new FilterStream((chunk, encoding, cb) => {\n  const mustBeFiltered = chunk.length() > 128;\n  if(mustBeFiltered) {\n    cb(true);\n    return;\n  }\n  cb(false);\n}, {\n  restore: true\n});\n\n// Print accepted chunks in stdout\nfilter.pipe(process.stdout);\n\n// Print filtered one to stderr\nfilter.restore.pipe(process.stderr);\n```\n\n### Filter and restore as a passthrough stream\nLet's reach total hype!\n\n```js\nimport FilterStream from 'streamfilter';\nimport { Transform } from 'stream';\n\n// Filter values\nconst filter = new FilterStream((chunk, encoding, cb) => {\n  const mustBeFiltered = chunk.length() > 128;\n  if(mustBeFiltered) {\n    cb(true);\n    return;\n  }\n  cb(false);\n}, {\n  restore: true,\n  passthrough: true\n});\n\n// Uppercase strings\nconst mySuperTransformStream = new Transform({\n  transform: (chunk, encoding, cb) => cb(\n    null,\n    Buffer.from(\n      chunk.toString(encoding).toUpperCase(),\n      encoding,\n    ),\n  ),\n});\n\n// Pipe stdin\nprocess.stdin.pipe(filter)\n  // Edit kept chunks\n  .pipe(mySuperTransformStream)\n  // Restore filtered chunks\n  .pipe(filter.restore)\n  // and output!\n  .pipe(process.stdout)\n```\n\nNote that in this case, this is *your* responsibility to end the restore stream\n by piping in another stream or ending him manually.\n\n[//]: # (::contents:end)\n\n# API\n<a name=\"StreamFilter\"></a>\n\n## StreamFilter(filterCallback, options) ⇒ <code>Stream</code>\nFilter piped in streams according to the given `filterCallback` that takes the\n following arguments: `chunk` the actual chunk, `encoding` the chunk encoding,\n filterResultCallback` the function to call as the result of the filtering\nprocess with `true` in argument to filter her or `false` otherwise.\n\nOptions are passed in as is in the various stream instances spawned by this\n module. So, to use the objectMode, simply pass in the `options.objectMode`\n value set to `true`.\n\n**Kind**: global function  \n**Returns**: <code>Stream</code> - The filtering stream  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| filterCallback | <code>function</code> | Callback applying the filters |\n| options | <code>Object</code> | Filtering options |\n| options.passthrough | <code>boolean</code> | Set to `true`, this option change the restore stream nature from a readable  stream to a passthrough one, allowing you to reuse the filtered chunks in an  existing pipeline. |\n| options.restore | <code>boolean</code> | Set to `true`, this option create a readable stream allowing you to use the  filtered chunks elsewhere. The restore stream is exposed in the `FilterStream`  instance as a `restore` named property. |\n\n\n# Authors\n- [Nicolas Froidure](http://insertafter.com/en/index.html)\n\n# License\n[MIT](https://github.com/nfroidure/streamfilter/blob/master/LICENSE)\n","publish_time":1512544891134,"_cnpm_publish_time":1512544891134,"dist-tags":{"latest":"4.0.0"}}