{"name":"stream-to-it","version":"0.2.2","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","delay":"^4.3.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":"f74f8ef129c5db999b79b4d4e75395d89fa18947","_id":"stream-to-it@0.2.2","_nodeVersion":"14.4.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-waULBmQpVdr6TkDzci6t1P7dIaSZ0bHC1TaPXDUeJC5PpSK7U3T0H0Zeo/LWUnd6mnhXOmGGDKAkjUCHw5IOng==","shasum":"fb3de7917424c354a987c7bc2aab2d0facbd7d94","tarball":"http://registry-npm.ywwl.com/stream-to-it/download/stream-to-it-0.2.2.tgz","fileCount":8,"unpackedSize":9301,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDsBSCRA9TVsSAnZWagAAcfcP/2/Pjw5YHBXHa/hqZAE3\nq4dA79z/LvUQLmklrTZzt6pLQxttrBSwU1izP5Oza+rxuKW2K8NrMJ8BAfZf\n7KcTUNE65lB7wA6NwePT7eMZa2/tNnmYiS574jblwcWGzJhbEeY6C8tfotGN\nm4KhDunYyPP3wfT9UChoie+DgtgqJWgZ9iBjyAvrwZ6W1wE2s0Uhb5q052aw\nYalcHIVb9zJLocQBn4Xn+HPwbA/midBThefWRV0QoTPFtiuJF/Qmmb6jIHbO\nLBjkMeHs/WPZsn+/J8aVmlytSjstcjMucuTdpnKn2HGuWAD7/L1gt8Vu7oUD\n1y+5rnxBd+mk2OuesYdZ1RUPrwmj+mnWo8mQs8F65l1BMYozkfJRcrpeO6l0\nzWHal2UZWoiqnOEsQ+ZIOsWQJqAUSr+R+rlAQVcsBAwb9y9PORxl1GoUU9FK\nhtRxr84nIhY1UJGsZqehgyx/jfBiTr6t3K3AnIIW0jyKLt2BV7+R6G8gnFye\n+ZiCXo1z4WZgpfeKl+YGMaNzckPDSQzgXmqmpwHQaLGJ5cVD+Dd60CePOthq\nvamXVw3BN2beXXZB9mVWSfoAAyWmCEULA4iqe1C6+i41QixoX+snWI71tgHd\nqzd6sQtfD37FkZEs5JicOqFNoIsDtNUmfg8Bo4p6794ziNzRQTDozSkSTzPd\nZIPu\r\n=3Scz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICMKpzNjkMZ1vVsGGPIzZMFjWuFOUHb3Tl+zt3l34Z4BAiEAtDftaXUIt6JdqwOdOWlsKxghjtm5RZnZwriEAVBWp3c="}],"size":3620,"noattachment":false,"key":"/stream-to-it/-/stream-to-it-0.2.2.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-to-it_0.2.2_1594802257646_0.5027071900211944"},"_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":1594802257748,"_cnpm_publish_time":1594802257748,"dist-tags":{"latest":"1.0.1"}}