{"name":"stream-to-it","version":"0.2.0","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","p-defer":"^3.0.0"},"devDependencies":{"ava":"^2.2.0","bl":"^4.0.0","it-pipe":"^1.0.1","nyc":"^14.1.1","p-fifo":"^1.0.0","standard":"^14.3.1","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":"13e8dcf573b73f477656c1e5291bf0f6654a9582","_id":"stream-to-it@0.2.0","_nodeVersion":"13.1.0","_npmVersion":"6.12.1","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-bK/N8LPMc4FgNxXwIRBbJDWg2GYUfnVGH++hTM5SjCHzyPPWYp2ml+wnqaO86+y0SywZDxPAZSNAPP3Wii/QzQ==","shasum":"43605aa82d9ebf5286d0c38939920d631bc9e9a4","tarball":"http://registry-npm.ywwl.com/stream-to-it/download/stream-to-it-0.2.0.tgz","fileCount":14,"unpackedSize":17808,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd58J2CRA9TVsSAnZWagAAOhcQAIGirI7Ugs6zlsXBfH0l\nbNZ9tjYxiCcRdaV0NboA/O6CBFHyUT27O2Ejz57sRF6SwLD7zqODkqb/jpgF\nlbghFBIKnUzd5S+E5WQbWcQ0esvQmsG0rvkQmNBJB9HVZIBGqncSL4B1ckPy\niMHoUYzgdcOe+4Q1gAbUOmVWN2iu9o8n2+qJFvrxPZIJ8hjF4LPWjxxob+p9\nrdAuduOSr878MV6qLon2NFn3B5xBHFHp9dbP91VUkGsTUlQ+LRfupWvrEonK\nH+y+J31RCv6CLHqCHBKK7Neh9bc6Mk2QvCURBdS7a3SzvVEllkg+76y8ZExn\noYP5vViJVj3T3fY1Q4gkjp3niNUg5HQKW2/Zo4LAwOKSPjlsYBpW8Jq8H5AO\nv39gsrFtgM/8QsyYVtloyfi1rS1lEjs55lKJkLcoYfxG1cORpBAT8y92gaIs\nxpPpNARd9HA1AhwXyKEEY8yD6zts6gkxlQaPD7yvC2yeZQmOEPVDKDZc3sl3\nILyP1/ocNCDQ6Kc4DIR9uuGKCboJj1qwoo/+SNP/wsGafC1a1s/zX2myR6oE\n1564NkxPv4lOwT020RzsnEuknDxm+px3otWmTWcM6v637Z12XnZjmma3BeHG\nn8x78k7xs3zLMIN4/IlcmXx7+dZz9zkXmavLFWHF4DrctBEaQweSJcQDqIm2\nKV5L\r\n=LTz3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCCpbrykLOr2NRZF10z2yMmOmr5w4x5x74x2CD2seznTAIhAIVqdn/2cTP9/NKGOEU0vylNvsNL0KMfR0qHji4yC1E8"}],"size":5157,"noattachment":false,"key":"/stream-to-it/-/stream-to-it-0.2.0.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-to-it_0.2.0_1575469685692_0.5605123065520807"},"_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":1575469685874,"_cnpm_publish_time":1575469685874,"dist-tags":{"latest":"1.0.1"}}