{"_id":"stream-wrapper","_rev":"237260","name":"stream-wrapper","description":"Wrap read/write/transform functions into streams","dist-tags":{"latest":"0.1.2"},"maintainers":[{"name":"mafintosh","email":""}],"time":{"modified":"2023-03-24T16:34:09.000Z","created":"2013-08-24T13:54:17.641Z","0.1.2":"2013-08-24T15:06:04.711Z","0.1.1":"2013-08-24T15:05:46.983Z","0.1.0":"2013-08-24T13:54:17.641Z"},"users":{},"author":{"name":"Mathias Buus Madsen","email":"mathiasbuus@gmail.com"},"repository":{"type":"git","url":"git://github.com/mafintosh/stream-wrapper.git"},"versions":{"0.1.2":{"name":"stream-wrapper","version":"0.1.2","repository":{"type":"git","url":"git://github.com/mafintosh/stream-wrapper.git"},"license":"MIT","description":"Wrap read/write/transform functions into streams","keywords":["streams2","stream","wrap","functional"],"author":{"name":"Mathias Buus Madsen","email":"mathiasbuus@gmail.com"},"dependencies":{"readable-stream":"~1.0.15","xtend":"~2.0.6"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/mafintosh/stream-wrapper/issues"},"_id":"stream-wrapper@0.1.2","dist":{"shasum":"468a9432c1012a1373c203085bbcb914869c31f6","size":2004,"noattachment":false,"key":"/stream-wrapper/-/stream-wrapper-0.1.2.tgz","tarball":"http://name.csiicloud.com:7001/stream-wrapper/download/stream-wrapper-0.1.2.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":""}],"directories":{},"publish_time":1377356764711,"_hasShrinkwrap":false,"_cnpm_publish_time":1377356764711,"_cnpmcore_publish_time":"2021-12-17T00:24:16.492Z"},"0.1.1":{"name":"stream-wrapper","version":"0.1.1","repository":{"type":"git","url":"git://github.com/mafintosh/stream-wrapper.git"},"license":"MIT","description":"Wrap read/write/transform functions into streams","keywords":["streams2","stream","wrap","functional"],"author":{"name":"Mathias Buus Madsen","email":"mathiasbuus@gmail.com"},"dependencies":{"readable-stream":"~1.0.15","xtend":"~2.0.6"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/mafintosh/stream-wrapper/issues"},"_id":"stream-wrapper@0.1.1","dist":{"shasum":"bfce1ae7016b2903b7e49425d8a3ffdf0d4c21e7","size":2008,"noattachment":false,"key":"/stream-wrapper/-/stream-wrapper-0.1.1.tgz","tarball":"http://name.csiicloud.com:7001/stream-wrapper/download/stream-wrapper-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":""}],"directories":{},"publish_time":1377356746983,"_hasShrinkwrap":false,"_cnpm_publish_time":1377356746983,"_cnpmcore_publish_time":"2021-12-17T00:24:16.924Z"},"0.1.0":{"name":"stream-wrapper","version":"0.1.0","repository":{"type":"git","url":"git://github.com/mafintosh/stream-wrapper.git"},"license":"MIT","description":"Create streams from read/write functions","keywords":["streams2","stream","wrap","functional"],"author":{"name":"Mathias Buus Madsen","email":"mathiasbuus@gmail.com"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/mafintosh/stream-wrapper/issues"},"_id":"stream-wrapper@0.1.0","dist":{"shasum":"287dbed22600f199474e407ec979df4c3ab473cb","size":1947,"noattachment":false,"key":"/stream-wrapper/-/stream-wrapper-0.1.0.tgz","tarball":"http://name.csiicloud.com:7001/stream-wrapper/download/stream-wrapper-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":""}],"directories":{},"publish_time":1377352457641,"_hasShrinkwrap":false,"_cnpm_publish_time":1377352457641,"_cnpmcore_publish_time":"2021-12-17T00:24:17.148Z"}},"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","_attachments":{},"readmeFilename":"README.md","bugs":{"url":"https://github.com/mafintosh/stream-wrapper/issues"},"license":"MIT"}