{"bugs":{"url":"https://github.com/mafintosh/stream-wrapper/issues"},"dist":{"shasum":"287dbed22600f199474e407ec979df4c3ab473cb","tarball":"https://registry.npmjs.org/stream-wrapper/-/stream-wrapper-0.1.0.tgz","integrity":"sha512-BFMHov55JJSaa+92MKVKLUtJSw/zTjcEgD4d9E7ttGsy/uLWULkraThthAVqzABlj5Ck2S5e/Q91UkqAn+czGw==","signatures":[{"sig":"MEUCIQD5nejCpRXyeUfS2AXuA+qAT3A6tVJvvmvqDe3pfB/8CQIgD6FhlQKD1VhntHYXtLdnxQxLDjDbhRtUjA22JyC43Bk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"name":"stream-wrapper","_from":".","author":{"name":"Mathias Buus Madsen","email":"mathiasbuus@gmail.com"},"readme":"# stream-wrapper\n\nDrop-in replacement for the core [stream](http://nodejs.org/api/stream.html)\nthat allows you to create streams from `read`/`write` functions.\n\n\tnpm install stream-wrapper\n\nAll streams create are stream2 streams\n\n## Readable Stream\n\n``` js\nvar stream = require('stream-wrapper');\n\nvar rs = stream.readable(function read(size) {\n\tthis.push(new Buffer('hello world'));\n});\n```\n\nIf you don't have a `read` function just omit it\n\n``` js\nvar rs = stream.readable();\nrs.push(new Buffer('hello world'));\n```\n\nThe Readable prototype is exposed through `stream.Readable`.\n\n## Writable Stream\n\n``` js\nvar stream = require('stream-wrapper');\n\nvar ws = stream.writable(function writable(chunk, enc, callback) {\n\tconsole.log('writing', chunk);\n\tcallback();\n});\n```\n\nThe Writable prototype is exposed through `stream.Writable`.\n\n## Duplex Stream\n\n``` js\nvar stream = require('stream-wrapper');\n\nvar ds = stream.duplex(function read() {\n\tthis.push(new Buffer('hello world'));\n}, function write(chunk, enc, callback) {\n\tconsole.log('writing', chunk);\n\tcallback();\n});\n```\n\nThe Duplex prototype is exposed through `stream.Duplex`\n\n## Transform Stream\n\n``` js\nvar stream = require('stream-wrapper');\n\nvar ts = stream.transform(function transform(chunk, enc, callback) {\n\tthis.push(chunk);\n\tcallback();\n});\n```\n\nIf you want to add a flush function pass it as the second parameter\n\n``` js\nvar ts = stream.transform(function transform() {\n\t...\n}, function flush(callback) {\n\tconsole.log('now flushing...');\n\tcallback();\n});\n```\n\nThe Transform prototype is exposed through `stream.Transform`\n\n## Stream options\n\nIf you want to pass stream options (like `objectMode`) pass them as the first\nparameter to `readable`, `writable`, `duplex` or `transform`\n\n``` js\nvar rs = stream.readable({objectMode:true}, function read() {\n\tthis.push({message:'i am an object'});\n});\n```\n\n## Stream defaults\n\nYou can change the default options for the stream by calling `defaults`\n\n``` js\n// all streams created have objectMode enabled\nstream = stream.defaults({objectMode:true});\n```\n\n## Stream.destroy\n\nAll streams have a `.destroy` method implemented per default that when called\nemits `close` and sets `stream.destroyed = true`.\n\n``` js\nvar rs = stream.readable();\n\nrs.on('close', function() {\n\t// rs.destroyed === true\n\tconsole.log('someone called destroy');\n});\n\nrs.destroy();\n```\n\n# License\n\nMIT","license":"MIT","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"keywords":["streams2","stream","wrap","functional"],"repository":{"url":"git://github.com/mafintosh/stream-wrapper.git","type":"git"},"_npmVersion":"1.3.8","description":"Create streams from read/write functions","directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"readmeFilename":"README.md","_id":"stream-wrapper@0.1.0","version":"0.1.0"}