{"name":"stream-to-it","version":"0.2.1","description":"Convert Node.js streams to streaming iterables","main":"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"},"devDependencies":{"ava":"^3.10.1","bl":"^4.0.0","it-pipe":"^1.1.0","nyc":"^15.1.0","p-fifo":"^1.0.0","standard":"^14.3.1","streaming-iterables":"^5.0.2"},"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":"6d71ca55ac96f2b76b12ac294086258f16bcb6eb","_id":"stream-to-it@0.2.1","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-pGJ5Z+EamGXyDvyeJ/go4vsIcLItG0YCrDFrxpc8kOWZHV5a5MhjN+RMyfRUcQEgCb8Vn3F0QUVeqb7WyUalVg==","shasum":"51c63fe99cdca71b1dc389c54057157cb4899fe2","tarball":"http://registry-npm.ywwl.com/stream-to-it/download/stream-to-it-0.2.1.tgz","fileCount":8,"unpackedSize":9076,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDHePCRA9TVsSAnZWagAAOvcP/0OJu9TivuKS9svHmbUT\nk0NSK0hAvP/US4ZLDwkgdrHRXclNEewJHMLhTFKCP7R+yBcE21wbikZRFZ7U\nk9xYObl+0fZpavblBQAYRYrKdk3/mH677Tik7KhPkXc1Fn9GqikrrYBh4d+E\nKN57OXl6yrPKcW6JcWtVH8wINVkpjVhAbhM1/G2egC5jAEGtLAFqR7dzpa72\nUZYoa+Ej7/SMjBFoa7zsuABnDfochCowoXE3nb1XEqcRvFvkgJ9J18NAE81c\nqLNf4DHG0sSgmKs7+AujvqphwJCJP0zwlj4LnEJFZHqK4e3rUNMrRB8aFims\nddlLFA7Yc6oNYh4Ipj4ePfaoSPItM/Mwr4nUUi+Tn+JCfOq5FLWMSxBU3fOA\n21q5Qvu1V5JaQPBu+lZjIKns09TOuCCoOD2fcCtntK+5VLlpa4n7wHadBDPP\nKH2U4d/p9b8MYiFovEVESY+mseLSwNBePPHYoVU/6xgQZ+sxgkuA0gS67OPj\ncriSbnDHzxuQCcjfYGp75zGk1UzOI51UH1KRvYnthF0ls+jOh+3fzumy2SQ0\nVAerV1JKthCEHv5H3PzrXGxPAHrzOc95YUpZbaLA0+dWnxtBbD5RhJlPCjYj\nqRFnT0aslOXgr76gARpu8sVIXwLvAI/2IV6ILDAnBjCptAOELs7bCnw7ECgC\n6VFj\r\n=XiSY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIARErqbZiTibrFtgGv4o46EHajQy+0aJNx/WVKcNP6GRAiAUnRw9trdh4BhrgWoqHX2bNr9YI67ehc+J9/S0auWGYw=="}],"size":3540,"noattachment":false,"key":"/stream-to-it/-/stream-to-it-0.2.1.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-to-it_0.2.1_1594652559019_0.9049733469148278"},"_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":1594652559158,"_cnpm_publish_time":1594652559158,"dist-tags":{"latest":"1.0.1"}}