{"id":15441184,"url":"https://github.com/alanshaw/stream-to-it","last_synced_at":"2025-04-13T00:06:46.483Z","repository":{"id":35070020,"uuid":"203164438","full_name":"alanshaw/stream-to-it","owner":"alanshaw","description":"🚰 Convert Node.js streams to streaming iterables","archived":false,"fork":false,"pushed_at":"2024-07-10T10:38:47.000Z","size":1013,"stargazers_count":18,"open_issues_count":4,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-30T12:03:41.011Z","etag":null,"topics":["convert-node-streams","readable-stream","stream","streaming-iterables"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alanshaw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-19T12:03:42.000Z","updated_at":"2024-04-15T08:41:25.000Z","dependencies_parsed_at":"2024-06-18T15:27:04.530Z","dependency_job_id":"c491994d-7bfd-4784-83d1-b150bca59ee6","html_url":"https://github.com/alanshaw/stream-to-it","commit_stats":{"total_commits":24,"total_committers":6,"mean_commits":4.0,"dds":"0.41666666666666663","last_synced_commit":"5975f0176f883645388f3af838e57b1bbded4b90"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fstream-to-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fstream-to-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fstream-to-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fstream-to-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alanshaw","download_url":"https://codeload.github.com/alanshaw/stream-to-it/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232726259,"owners_count":18567084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convert-node-streams","readable-stream","stream","streaming-iterables"],"created_at":"2024-10-01T19:17:24.628Z","updated_at":"2025-01-06T13:22:32.244Z","avatar_url":"https://github.com/alanshaw.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"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\\\u0026style=flat-square)](https://github.com/alanshaw/stream-to-it/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)\n\n\u003e Convert Node.js streams to streaming iterables\n\n# About\n\n\u003c!--\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--\u003e\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 =\u003e s\nconst source = toIterable.source\u003cBuffer\u003e(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 =\u003e {\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- \u003chttps://alanshaw.github.io/stream-to-it\u003e\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / \u003chttp://opensource.org/licenses/MIT\u003e)\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanshaw%2Fstream-to-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falanshaw%2Fstream-to-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanshaw%2Fstream-to-it/lists"}