{"_id":"it-to-stream","_rev":"4573604","name":"it-to-stream","description":"Convert streaming iterables to Node.js streams","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"alanshaw","email":""}],"time":{"modified":"2026-04-10T15:35:23.000Z","created":"2019-07-31T14:20:42.556Z","1.0.0":"2021-04-08T08:12:44.872Z","0.1.2":"2020-07-02T19:53:23.504Z","0.1.1":"2019-07-31T17:06:45.859Z","0.1.0":"2019-07-31T14:20:42.556Z"},"users":{},"author":{"name":"Alan Shaw"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-to-stream.git"},"versions":{"1.0.0":{"name":"it-to-stream","version":"1.0.0","description":"Convert streaming iterables to Node.js streams","main":"src/index.js","browser":{"stream":"readable-stream"},"scripts":{"test":"ava test/*.test.js --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["stream","readablestream"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"buffer":"^6.0.3","fast-fifo":"^1.0.0","get-iterator":"^1.0.2","p-defer":"^3.0.0","p-fifo":"^1.0.0","readable-stream":"^3.6.0"},"devDependencies":{"ava":"^3.9.0","it-pair":"^1.0.0","nyc":"^15.1.0","standard":"^16.0.3"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-to-stream.git"},"bugs":{"url":"https://github.com/alanshaw/it-to-stream/issues"},"homepage":"https://github.com/alanshaw/it-to-stream#readme","gitHead":"082f0ad069d35f7f8608e905beffd6ac9176806c","_id":"it-to-stream@1.0.0","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"shasum":"6c47f91d5b5df28bda9334c52782ef8e97fe3a4a","size":4827,"noattachment":false,"key":"/it-to-stream/-/it-to-stream-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/it-to-stream/download/it-to-stream-1.0.0.tgz"},"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"maintainers":[{"name":"alanshaw","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-to-stream_1.0.0_1617869564701_0.19280600201734854"},"_hasShrinkwrap":false,"publish_time":1617869564872,"_cnpm_publish_time":1617869564872,"_cnpmcore_publish_time":"2021-12-16T13:35:32.984Z"},"0.1.2":{"name":"it-to-stream","version":"0.1.2","description":"Convert streaming iterables to Node.js streams","main":"src/index.js","browser":{"stream":"readable-stream"},"scripts":{"test":"ava test/*.test.js --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["stream","readablestream"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"buffer":"^5.6.0","fast-fifo":"^1.0.0","get-iterator":"^1.0.2","p-defer":"^3.0.0","p-fifo":"^1.0.0","readable-stream":"^3.6.0"},"devDependencies":{"ava":"^3.9.0","it-pair":"^1.0.0","nyc":"^15.1.0","standard":"^14.3.4"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-to-stream.git"},"bugs":{"url":"https://github.com/alanshaw/it-to-stream/issues"},"homepage":"https://github.com/alanshaw/it-to-stream#readme","gitHead":"d7e9611ce126f9ea4282459bc85be1fa0c18ee2a","_id":"it-to-stream@0.1.2","_nodeVersion":"14.4.0","_npmVersion":"6.14.5","dist":{"shasum":"7163151f75b60445e86b8ab1a968666acaacfe7b","size":4788,"noattachment":false,"key":"/it-to-stream/-/it-to-stream-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/it-to-stream/download/it-to-stream-0.1.2.tgz"},"maintainers":[{"name":"alanshaw","email":""}],"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-to-stream_0.1.2_1593719603319_0.9642184834573542"},"_hasShrinkwrap":false,"publish_time":1593719603504,"_cnpm_publish_time":1593719603504,"_cnpmcore_publish_time":"2021-12-16T13:35:33.202Z"},"0.1.1":{"name":"it-to-stream","version":"0.1.1","description":"Convert streaming iterables to Node.js streams","main":"src/index.js","browser":{"stream":"readable-stream"},"scripts":{"test":"ava test/*.test.js --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["stream","readablestream"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"buffer":"^5.2.1","fast-fifo":"^1.0.0","get-iterator":"^1.0.2","p-defer":"^3.0.0","p-fifo":"^1.0.0","readable-stream":"^3.4.0"},"devDependencies":{"ava":"^2.2.0","it-pair":"^1.0.0","nyc":"^14.1.1","standard":"^13.1.0"},"ava":{"babel":false,"compileEnhancements":false},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-to-stream.git"},"bugs":{"url":"https://github.com/alanshaw/it-to-stream/issues"},"homepage":"https://github.com/alanshaw/it-to-stream#readme","gitHead":"f7ce5a96976e4abdfdd4359a6a2ba8eda7420367","_id":"it-to-stream@0.1.1","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"shasum":"3fb4a9c4df868cd8f4aaf2071eba5ada5a3fad2a","size":4624,"noattachment":false,"key":"/it-to-stream/-/it-to-stream-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/it-to-stream/download/it-to-stream-0.1.1.tgz"},"maintainers":[{"name":"alanshaw","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-to-stream_0.1.1_1564592805736_0.10477427614158552"},"_hasShrinkwrap":false,"publish_time":1564592805859,"_cnpm_publish_time":1564592805859,"_cnpmcore_publish_time":"2021-12-16T13:35:33.694Z"},"0.1.0":{"name":"it-to-stream","version":"0.1.0","description":"Convert streaming iterables to Node.js streams","main":"src/index.js","browser":{"stream":"readable-stream"},"scripts":{"test":"ava test/*.test.js --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["stream","readablestream"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"buffer":"^5.2.1","fast-fifo":"^1.0.0","get-iterator":"^1.0.2","p-defer":"^3.0.0","p-fifo":"^1.0.0","readable-stream":"^3.4.0"},"devDependencies":{"ava":"^2.2.0","it-pair":"^1.0.0","nyc":"^14.1.1","standard":"^13.1.0"},"ava":{"babel":false,"compileEnhancements":false},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/it-to-stream.git"},"bugs":{"url":"https://github.com/alanshaw/it-to-stream/issues"},"homepage":"https://github.com/alanshaw/it-to-stream#readme","gitHead":"fadd1dbdd0fbef29c99b584e79b039e807086093","_id":"it-to-stream@0.1.0","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"shasum":"52685e252ea5918fdc542601b6ccd7920dbfacbb","size":4938,"noattachment":false,"key":"/it-to-stream/-/it-to-stream-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/it-to-stream/download/it-to-stream-0.1.0.tgz"},"maintainers":[{"name":"alanshaw","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-to-stream_0.1.0_1564582842416_0.40503647996484937"},"_hasShrinkwrap":false,"publish_time":1564582842556,"_cnpm_publish_time":1564582842556,"_cnpmcore_publish_time":"2021-12-16T13:35:33.967Z"}},"readme":"# it-to-stream\n\n[![Build Status](https://travis-ci.org/alanshaw/it-to-stream.svg?branch=master)](https://travis-ci.org/alanshaw/it-to-stream)\n[![dependencies Status](https://status.david-dm.org/gh/alanshaw/it-to-stream.svg)](https://david-dm.org/alanshaw/it-to-stream)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n> Convert streaming iterables to Node.js streams\n\n## Install\n\n```sh\nnpm i it-to-stream\n```\n\n## Usage\n\n```js\nconst toStream = require('it-to-stream')\n```\n\n### Convert source iterable to readable stream\n\n```js\n// A streaming iterable \"source\" is just an (async) iterable\nconst source = (async function * () {\n  for (const value of [1, 2, 3, 4]) yield Buffer.from(value.toString())\n})()\n\nconst readable = toStream.readable(source)\n\n// Now we have a readable stream, we can consume it by\nreadable.on('data', console.log)\n// or\nreadable.pipe(writable)\n// or\npipeline(readable, writable, err => console.log(err || 'done'))\n```\n\n### Convert sink iterable to writable stream\n\n```js\n// A streaming iterable \"sink\" is an (async) function that takes a \"source\"\n// and consumes it.\nconst sink = async source => {\n  for await (const chunk of source) {\n    console.log(chunk.toString())\n  }\n}\n\nconst writable = toStream.writable(sink)\n\n// Now we have a writable stream, we can pipe to it\nfs.createReadStream('/path/to/file').pipe(writable)\n```\n\n### Convert transform iterable to transform stream\n\n```js\n// A streaming iterable \"transform\" is a function that takes a \"source\" and\n// returns a \"source\".\nconst transform = source => (async function * () {\n  for await (const chunk of source) {\n    // Replace all space characters with dashes\n    yield Buffer.from(chunk.toString().replace(/ /g, '-'))\n  }\n})()\n\nconst transform = toStream.transform(transform)\n\n// Now we have a transform stream, we can pipe to and from it\nfs.createReadStream('/path/to/file')\n  .pipe(transform)\n  .pipe(fs.createWriteStream('/path/to/file2'))\n```\n\n## API\n\n```js\nconst toStream = require('it-to-stream')\n```\n\n### `toStream.readable(source, [options]): Readable`\n\nConvert a [source](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#source-it) iterable to a [`Readable`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams) stream.\n\n`options` are passed directly to the `Readable` constructor.\n\n### `toStream.writable(sink, [options]): Writable`\n\nConvert a [sink](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#sink-it) iterable to a [`Writable`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_writable_streams) stream.\n\n`options` are passed directly to the `Writable` constructor.\n\n### `toStream.transform(transform, [options]): Transform`\n\nConvert a [transform](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#transform-it) iterable to a [`Transform`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_duplex_and_transform_streams) stream.\n\n`options` are passed directly to the `Transform` constructor.\n\n### `toStream.duplex(duplex, [options]): Duplex`\n\nConvert a [duplex](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it) iterable to a [`Duplex`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_duplex_and_transform_streams) stream.\n\n`options` are passed directly to the `Duplex` constructor.\n\n## Related\n\n* [`stream-to-it`](https://www.npmjs.com/package/stream-to-it) Convert Node.js streams to streaming iterables\n* [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to \"pipe\" async iterables together\n\n## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/alanshaw/it-to-stream/issues/new) or submit PRs.\n\n## License\n\n[MIT](LICENSE) © Alan Shaw\n","_attachments":{},"homepage":"https://github.com/alanshaw/it-to-stream#readme","bugs":{"url":"https://github.com/alanshaw/it-to-stream/issues"},"license":"MIT"}