{"name":"pass-stream","description":"pass-through stream which can filter/adapt and pause data as it passes through (streams2)","version":"1.0.0","author":{"name":"Jeff Barczewski","email":"jeff.barczewski@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/jeffbski/pass-stream.git"},"bugs":{"url":"http://github.com/jeffbski/pass-stream/issues"},"licenses":[{"type":"MIT","url":"http://github.com/jeffbski/pass-stream/raw/master/LICENSE"}],"main":"lib/pass-stream","engines":{"node":">=0.10"},"dependencies":{},"devDependencies":{"mocha":"~1.9.0","chai":"~1.5.0","chai-stack":"~1.3.1"},"scripts":{"test":"./node_modules/mocha/bin/mocha ./test/*.mocha.js"},"keywords":["stream","streams2","filter","transform","through","pipe","pause","drain","buffer"],"gitHead":"221f788c218d5f0c5f4c32775c4e4cfb064d9a91","homepage":"https://github.com/jeffbski/pass-stream#readme","_id":"pass-stream@1.0.0","_shasum":"72850ad6b20ff7a2724a780f50e2506200b61e82","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"jeffbski","email":"jeff.barczewski@gmail.com"},"dist":{"shasum":"72850ad6b20ff7a2724a780f50e2506200b61e82","tarball":"http://registry-npm.ywwl.com/pass-stream/download/pass-stream-1.0.0.tgz","integrity":"sha512-hqejLFE/hk60iSdC1ucocFL7dufoUO7W6H4l5247LJu8e+vjjvrQdVDuL2zKqwK6ohdz8HsvA63Ny05kJVIO7Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHiuRJhAwueXrPfN6sHtS0kybiIlOWAKmrUkt5Z2bQ1NAiEA8DbRHJgMmkM5qy1fdGo2gmsj+02kV3y3jMud+NaOrec="}],"size":4858,"noattachment":false,"key":"/pass-stream/-/pass-stream-1.0.0.tgz"},"maintainers":[{"name":"jeffbski","email":"jeff.barczewski@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/pass-stream-1.0.0.tgz_1488576727102_0.7907904300373048"},"readme":"# pass-stream - pass-through node.js stream which can filter/adapt and pause data\n\npass-stream is a pass-through stream which allows transform fns for easily filtering or adapting the data that flows through the stream.\n\nIt is a light wrapper over the new (streams2) readable-stream functionality which is available as add in for node 0.8 and is built-in for node 0.10+\n\n[![Build Status](https://secure.travis-ci.org/jeffbski/pass-stream.png?branch=master)](http://travis-ci.org/jeffbski/pass-stream)\n\n## Installation\n\n```bash\nnpm install pass-stream\n```\n\n## Usage\n\n - `passStream(writeFn, endFn, options)` optional writeFn, endFn, and options. Returns a pauseable stream which can be piped or used like any other. Options are the same as for standard streams (for instance set objectMode = true to allow arbitrary non-null objects to be used.\n\n\n```javascript\nvar passStream = require('pass-stream');\nvar ps = passStream(); // constructing stream without any transformations\nreadStream\n  .pipe(ps)\n  .pipe(anotherStream)\n```\n\nTo add transform/filter functionality you may provide a writeFn and/or endFn which allows you to tap into the write and end processing.\n\nIf you provide a writeFn, then it is up to you to call `this.push(data)` with whatever transformed data and call the cb. The writeFn has signature `writeFn(chunk, encoding, cb)`\n\nIf you provide an endFn, then it will be be fired after all the data has been read but before the `end` event has been fired. You may do additional `this.push(data)` and then call the cb when done. hooked up as a listener for `on('end')`. The endFn has signature `endFn(cb)`.\n\nThe `cb` functions provided in writeFn and endFn can call the callback with an error if they wish to signal an error to the stream, ex: `cb(new Error('bad...'))`\n\nThe `this` context of the writeFn and endFn is set to that of the stream so you have all the normal stream functions like `emit`, `pause`, and `resume`. Note: you will not want to call `write` or `end` from within these functions since they will cause a recursive loop.\n\n```javascript\nvar passStream = require('pass-stream');\n  var length = 0;\n  function writeFn(data, encoding, cb) { // we are assuming data is strings\n    this.push(data.toUpperCase());  // upper case\n    length += data.length;  // keep track of length\n    cb();\n  }\n  function endFn(cb) {\n    this.emit('length', length); // emit length now that it is done\n    cb();\n  }\n  var lengthResult = 0;\n  var options = {};\n  var rstream = new Stream();\n  rstream\n    .pipe(passStream(writeFn, endFn, options))  // construct a passStream with transformFns\n    .on('length', function (len) { lengthResult = len; })\n    .pipe(anotherStream);\n```\n\n\n## Goals\n\n - Easily use new streams2 functionality (readable-streams) with node 0.8 or 0.10+\n - Built-in buffering pause capability (from streams2)\n - Easy to use transformation filters with the stream\n - Act as the base to build other specific pass through streams with\n - Tested\n - Allows any datatype (except null or undefined) to be used in the stream (String, Buffer, Number, Boolean, Array, Object)\n\n## Why\n\nWhile node 0.8 is still needed, this creates easy wrapper to allow for the transition to node 0.10\n\n\n## Get involved\n\nIf you have input or ideas or would like to get involved, you may:\n\n - contact me via twitter @jeffbski  - <http://twitter.com/jeffbski>\n - open an issue on github to begin a discussion - <https://github.com/jeffbski/pass-stream/issues>\n - fork the repo and send a pull request (ideally with tests) - <https://github.com/jeffbski/pass-stream>\n\n## License\n\n - [MIT license](http://github.com/jeffbski/pass-stream/raw/master/LICENSE)\n","publish_time":1488576729463,"_cnpm_publish_time":1488576729463,"dist-tags":{"latest":"1.0.0"}}