{"name":"pass-stream","description":"pass-through stream which can filter/adapt and pause data as it passes through","version":"0.0.7","author":{"name":"Jeff Barczewski","email":"jeff.barczewski@gmail.com"},"repository":{"type":"git","url":"http://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.8"},"dependencies":{"pause-stream":"=0.0.7"},"devDependencies":{"mocha":"~1.8.2","chai":"~1.5.0","chai-stack":"~1.3.1","stream-tester":"~0.0.5","stream-spec":"~0.3.1"},"scripts":{"test":"./node_modules/mocha/bin/mocha ./test/*.mocha.js"},"keywords":["stream","filter","transform","through","pipe","pause","drain","buffer"],"_id":"pass-stream@0.0.7","dist":{"shasum":"7b2dc11447be84d14903e3ae1417d5a40c6f0b74","tarball":"http://registry-npm.ywwl.com/pass-stream/download/pass-stream-0.0.7.tgz","integrity":"sha512-oxi7MClbIqFJyepnwXf/JrKLMFtBGqLI7/JjWRJyB1Ne8P03zISNgNpO3BqSwZdNO9LFQl/LtrH6IrPhQjmOXw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPcdezI8n9CKgZiha49RkrPudT7KBCLNnIBDn5t3idnwIhAKKJa54tu+FQAv1tqB8jpazKuUvj3c8Hql89c0KfIVOi"}],"size":6115,"noattachment":false,"key":"/pass-stream/-/pass-stream-0.0.7.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jeffbski","email":"jeff.barczewski@gmail.com"},"maintainers":[{"name":"jeffbski","email":"jeff.barczewski@gmail.com"}],"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":1364072772916,"_cnpm_publish_time":1364072772916,"dist-tags":{"latest":"1.0.0"}}