{"name":"stream-to-it","version":"0.2.3","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":"^5.0.0","delay":"^5.0.0","it-pipe":"^1.1.0","nyc":"^15.1.0","p-fifo":"^1.0.0","standard":"^16.0.3","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":"fe19c61b9b5b3912c84a2bb91a41071422246455","_id":"stream-to-it@0.2.3","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-xaK9EjPtLox5rrC7YLSBXSanTtUJN/lzJlMFvy9VaROmnyvy0U/X6m2uMhXPJRn3g3M9uOSIzTszW7BPiWSg9w==","shasum":"b9320ceb26a51b313de81036d4354d9b657f4d2d","tarball":"http://registry-npm.ywwl.com/stream-to-it/download/stream-to-it-0.2.3.tgz","fileCount":8,"unpackedSize":9304,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeV2UCRA9TVsSAnZWagAApTkP/Rb0x1SI4pB5EOWLiRDC\n74CLowb6ChVeIsvdEn81TDuVWxX7gpQ0EC+nqH+PiU+a7q5+X1J/rbk5ZGve\nsYKC5Tqs9HdjZATDTKhfr1LzogpGdsXaW7MxNasXo355z2JtqW8OdhLJYGA5\nQuxVkoOnL3YZbtdbKqhc4xPeW/1Ummo1RUQqDJbc/Rn5dZq4zisxX9L5hFHL\nvYZAswMeDIQapZhw5NymZ9vTRWIAam+aF7p70C051oGUGnKsfjBPRJnP4/CQ\ndiwzyDf4a1CKAxwN5/0DeXrZA05pbC6V9lMJNN718yCOVAYT5NtwC22VEvOr\nzL/C4tIPFZr4ETDbUsbwwWB9xhzmbxFkKY/FCUOKz6P/rW6cUtOHNwMzHS29\n0ZjuTkeS5Z/55uSMI69plSryHJq3phPtsPCOvYhaAKw4Ju9uVB9V0oz0AJb/\nQxn+yQ3NWsnS8DRrTXCQe6SjqBdw3cwX4QsmakyHYIrLNaTdDs9GRv/Bq/wf\nLH7dUpluoDl1PvUgbcNC0XzYX3KaIZJ9m+Aw+PySf+zffftUZkNVACOfttKk\nfkEEUA/th1vAWS+eG+avxK5MRhGsav41aZchEmGjh3cjRXyfWsXGi2U8vtul\njkPluyUHdz75ggtQcdqIwzYxxGL5eRAr+EKWV/hcZOTe1hscORtnINjzWcQx\nMFHB\r\n=UBbt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDnJ87rp5cCllVQGpY0lPb5ipG67C0KwDT8s2QXWIFgBwIhAIFgmjPEqZj+SMvUJJF1FkC45z2tQwxOac0AN0/vHdGj"}],"size":3622,"noattachment":false,"key":"/stream-to-it/-/stream-to-it-0.2.3.tgz"},"_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-to-it_0.2.3_1618566548187_0.6591832480314186"},"_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":1618566548298,"_cnpm_publish_time":1618566548298,"dist-tags":{"latest":"1.0.1"}}