{"name":"streamfilter","version":"1.0.5","description":"Filtering streams.","main":"src/index.js","scripts":{"test":"mocha tests/*.mocha.js","coveralls":"./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage","cover":"./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report html -- tests/*.mocha.js -R spec -t 5000","lint":"eslint **/*.s","cli":"env NPM_RUN_CLI=1"},"repository":{"type":"git","url":"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":{"coveralls":"^2.11.3","eslint":"^1.0.0","istanbul":"^0.3.17","mocha":"^2.2.5","sf-lint":"^1.0.2","streamtest":"^1.2.1"},"dependencies":{"readable-stream":"^2.0.2"},"gitHead":"0c0c8a117b79cca6ceb69ab5dbd1789e1ee57e2f","_id":"streamfilter@1.0.5","_shasum":"87507111beb8e298451717b511cfed8f002abf53","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"nfroidure","email":"nfroidure@elitwork.com"},"dist":{"shasum":"87507111beb8e298451717b511cfed8f002abf53","tarball":"http://registry-npm.ywwl.com/streamfilter/download/streamfilter-1.0.5.tgz","integrity":"sha512-IHuyNEAPs3pi2ABhJ7Dbjza9Gc6Nq7NDvx14tsKw4h4cMUz4YoLOON6nghUvIZVO4NW4qvYUoED1kd6/bipTVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCW6ZHwQefsSDviEJWNCFz+kJunFBRe3kE57U+1XMuFRQIhAJhlCmkF7mGVsas5tqmUqW94Z82ZYQSimVvJegzxx9Bj"}],"size":6568,"noattachment":false,"key":"/streamfilter/-/streamfilter-1.0.5.tgz"},"maintainers":[{"name":"nfroidure","email":"nfroidure@elitwork.com"}],"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":1440147027633,"_cnpm_publish_time":1440147027633,"dist-tags":{"latest":"4.0.0"}}