{"name":"stream-to-it","version":"0.1.0","description":"Convert Node.js streams to streaming iterables","main":"src/index.js","scripts":{"test":"ava test/*.test.js --verbose","lint":"standard","coverage":"nyc --reporter=text --reporter=lcov npm test"},"keywords":["stream","readablestream","iterable","iterator","async"],"author":{"name":"Alan Shaw"},"license":"MIT","dependencies":{"get-iterator":"^1.0.2","p-defer":"^3.0.0"},"devDependencies":{"ava":"^2.2.0","bl":"^3.0.0","it-pipe":"^1.0.1","nyc":"^14.1.1","p-fifo":"^1.0.0","standard":"^13.1.0","streaming-iterables":"^4.1.0"},"ava":{"babel":false,"compileEnhancements":false},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/stream-to-it.git"},"bugs":{"url":"https://github.com/alanshaw/stream-to-it/issues"},"homepage":"https://github.com/alanshaw/stream-to-it#readme","gitHead":"e2b16a89dd7e8acdf2a89bfbcd02a41c47153300","_id":"stream-to-it@0.1.0","_nodeVersion":"12.7.0","_npmVersion":"6.10.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-bdtPkoW6Fe3BnKQaDxcrmo4Ba5VbKQer8ciXfeIVZtvJHaukEvdN/vIxKEnamWahoMHdicv8JRrKgQKDM6kDvw==","shasum":"df62c11d32839e85a3b601fe8f81bae66c502d83","tarball":"http://registry-npm.ywwl.com/stream-to-it/download/stream-to-it-0.1.0.tgz","fileCount":11,"unpackedSize":15457,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdWpHECRA9TVsSAnZWagAAFkgP/RkaXitDpN+HnNnVxso9\nv7FfK5em/mptZL6vtp5ws9IYpiPRa2vJ7YI5tT48X1dgHVAiYKmUxuLi7BCp\nO7FVJI9wpbjYxmRV3pTQMgbN6/SfMq0xknFlw3a8CqmTI8bevDClEvvTIUJv\nJojsdiTAQhfDN6pDpsu//j5zLSt0SjDUOi5ijnvxFp9RUm0O8/jNbjR6+229\nuGULSTWdPMsTZwT8MnCW4enniwd7T0xhSdHEukbpx2cQ/nckr7LVunJcj7c9\nVJ37XoqDFeuGH+Pf1qzfi6Y7WBlTp5cVPXgyGaTE5RakVlhqqapOKt44apIF\nFAIF/C5E5VxgKOVURODcF8zssYFw3y4wZPwD4rxuZfRw2NXx48F6VGku8eUi\ncc51TiqwoTUFQ9QdaNyDWUoWoIvb2n0zHj6eSvl9iE/QYLZNiwYjBiqWNAYK\nCIiQpU4bdH/2cZ1ZZgFlCR3Xb182VCC2B7pmNU1C42yyg4/2cAi/exhvcWLO\nZ/YO8/G/nQ2Rm52uSrXXIglS00WQCwbgix/g0v1l68ue+mbbjDhysOg88wv4\njMCPjMrUTwyyaTGrBiTl6wNa03KVqHrvrKons4uPgBRkIBYh5ZtAmblzQSkR\nOupis9picmIm2/Ks+6FfGhnOslKMS7pqjRUe14FlF/Ykou+jlAhYsmd5Mk4z\ng2dy\r\n=5VdE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXE4s0DKR5w3heLBfugeDfKtF9SVb4FEOccviH/vJ1BQIhAJwfvrL8TYc+tTWiTRhl0/fb5lvetBsngxqtgr7LRrAi"}],"size":4535,"noattachment":false,"key":"/stream-to-it/-/stream-to-it-0.1.0.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-to-it_0.1.0_1566216643756_0.6813803706522341"},"_hasShrinkwrap":false,"readme":"# stream-to-it\n\n[![codecov](https://img.shields.io/codecov/c/github/alanshaw/stream-to-it.svg?style=flat-square)](https://codecov.io/gh/alanshaw/stream-to-it)\n[![CI](https://img.shields.io/github/actions/workflow/status/alanshaw/stream-to-it/js-test-and-release.yml?branch=master\\&style=flat-square)](https://github.com/alanshaw/stream-to-it/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)\n\n> Convert Node.js streams to streaming iterables\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\nSeamlessly use Node.js streams with `it-pipe` and friends.\n\n## Example - Convert readable stream to source iterable\n\n```TypeScript\nimport fs from 'node:fs'\nimport * as toIterable from 'stream-to-it'\n\nconst readable = fs.createReadStream('/path/to/file')\n// Node.js streams are already async iterable so this is just s => s\nconst source = toIterable.source<Buffer>(readable)\n\nfor await (const chunk of source) {\n  console.log(chunk.toString())\n}\n```\n\nAlso works with browser [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream):\n\n```TypeScript\nimport * as toIterable from 'stream-to-it'\n\nconst res = await fetch('http://example.org/file.jpg')\n\nif (res.body == null) {\n  throw new Error('Body was not set')\n}\n\nfor await (const chunk of toIterable.source(res.body)) {\n  console.log(chunk.toString())\n}\n```\n\n## Example - Convert writable stream to sink iterable\n\n```TypeScript\nimport fs from 'node:fs'\nimport { pipe } from 'it-pipe'\nimport * as toIterable from 'stream-to-it'\n\nconst source = [Buffer.from('Hello '), Buffer.from('World!')]\nconst sink = toIterable.sink(fs.createWriteStream('/path/to/file'))\n\nawait pipe(source, sink)\n```\n\n## Example - Convert transform stream to transform iterable\n\n```TypeScript\nimport fs from 'node:fs'\nimport { Transform } from 'node:stream'\nimport { pipe } from 'it-pipe'\nimport * as toIterable from 'stream-to-it'\n\nconst output = await pipe(\n  [true, false, true, true],\n  toIterable.transform(new Transform({ // Inverter transform :)\n    transform (chunk, enc, cb) {\n      cb(null, !chunk)\n    }\n  })),\n  // Collect and return the chunks\n  async source => {\n    const chunks = []\n    for await (const chunk of source) chunks.push(chunk)\n    return chunks\n  }\n)\n\nconsole.log(output) // [ false, true, false, false ]\n```\n\n## Related\n\n- [`it-to-stream`](https://www.npmjs.com/package/it-to-stream) Convert streaming iterables to Node.js streams\n- [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to \"pipe\" async iterables together\n\n# Install\n\n```console\n$ npm i stream-to-it\n```\n\n# API Docs\n\n- <https://alanshaw.github.io/stream-to-it>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1566216643900,"_cnpm_publish_time":1566216643900,"dist-tags":{"latest":"1.0.1"}}