{"id":15408924,"url":"https://github.com/sec-ant/readable-stream","last_synced_at":"2025-10-13T12:31:59.407Z","repository":{"id":63713428,"uuid":"569980966","full_name":"Sec-ant/readable-stream","owner":"Sec-ant","description":"A tiny, zero-dependency yet spec-compliant asynchronous iterator polyfill/ponyfill for ReadableStreams.","archived":false,"fork":false,"pushed_at":"2025-10-06T17:58:38.000Z","size":444,"stargazers_count":7,"open_issues_count":10,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T19:36:36.749Z","etag":null,"topics":["async","iterable","iteration","iterator","polyfill","ponyfill","readable-stream","stream"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@sec-ant/readable-stream/v/latest","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sec-ant.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-11-24T04:03:00.000Z","updated_at":"2025-09-29T02:22:12.000Z","dependencies_parsed_at":"2024-04-08T03:27:00.675Z","dependency_job_id":"9272bef2-6d6f-4c4d-a216-c90d6a5efcad","html_url":"https://github.com/Sec-ant/readable-stream","commit_stats":{"total_commits":37,"total_committers":1,"mean_commits":37.0,"dds":0.0,"last_synced_commit":"fa9a5e0a3ae93ce300f92b250d375899b7b451b5"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Sec-ant/readable-stream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Freadable-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Freadable-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Freadable-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Freadable-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sec-ant","download_url":"https://codeload.github.com/Sec-ant/readable-stream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Freadable-stream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015056,"owners_count":26085643,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["async","iterable","iteration","iterator","polyfill","ponyfill","readable-stream","stream"],"created_at":"2024-10-01T16:35:59.973Z","updated_at":"2025-10-13T12:31:59.344Z","avatar_url":"https://github.com/Sec-ant.png","language":"TypeScript","readme":"# @sec-ant/readable-stream\n\n[![npm version](https://img.shields.io/npm/v/@sec-ant/readable-stream?cacheSeconds=300)](https://www.npmjs.com/package/@sec-ant/readable-stream/v/latest) [![npm downloads](https://img.shields.io/npm/dm/@sec-ant/readable-stream?cacheSeconds=300)](https://www.npmjs.com/package/@sec-ant/readable-stream/v/latest) [![](https://img.shields.io/jsdelivr/npm/hm/@sec-ant/readable-stream?cacheSeconds=300\u0026color=ff5627)](https://www.jsdelivr.com/package/npm/@sec-ant/readable-stream) [![bundlephobia minzipped](https://img.shields.io/bundlephobia/minzip/@sec-ant/readable-stream?cacheSeconds=300)](https://bundlephobia.com/package/@sec-ant/readable-stream@latest) [![npm license](https://img.shields.io/npm/l/@sec-ant/readable-stream?cacheSeconds=300)](https://www.npmjs.com/package/@sec-ant/readable-stream/v/latest)\n\nA tiny, zero-dependency yet spec-compliant asynchronous iterator polyfill/ponyfill for [`ReadableStream`](https://developer.mozilla.org/docs/Web/API/ReadableStream)s.\n\n## Features\n\n### Asynchronously iterate a `ReadableStream`\n\nWith this package, you can consume a `ReadableStream` as an `AsyncIterable`.\n\n- spec: https://streams.spec.whatwg.org/#rs-asynciterator\n- tests: https://github.com/Sec-ant/readable-stream/blob/main/tests/asyncIterator.spec.ts (copied from [wpt](https://github.com/web-platform-tests/wpt/blob/309231a7f3e900d04914bc4963b016efd9989a00/streams/readable-streams/async-iterator.any.js))\n\n### Convert an `AsyncIterable` or an `Iterable` into a `ReadableStream`\n\nWith this package, you can construct a `ReadableStream` from an `AsyncIterable` or an `Iterable`.\n\n- spec: https://streams.spec.whatwg.org/#rs-from\n- tests: https://github.com/Sec-ant/readable-stream/blob/main/tests/fromAnyIterable.spec.ts (copied from [wpt](https://github.com/web-platform-tests/wpt/blob/309231a7f3e900d04914bc4963b016efd9989a00/streams/readable-streams/from.any.js))\n\nThis package passes all the aforementioned tests.\n\n## Install\n\n```bash\nnpm i @sec-ant/readable-stream\n```\n\n## Usage\n\n### Ponyfill\n\nThis package can be imported as a _ponyfill_ to avoid side effects:\n\n#### `asyncIterator`\n\nPath:\n\n```\n@sec-ant/readable-stream/ponyfill/asyncIterator\n```\n\nExample:\n\n```ts\nimport {\n  asyncIterator,\n  type ReadableStreamIteratorOptions,\n} from \"@sec-ant/readable-stream/ponyfill/asyncIterator\";\n\nconst readableStream = (await fetch(\"https://www.example.org/\")).body;\n\nlet total = 0;\nfor await (const chunk of asyncIterator(readableStream)) {\n  total += chunk.length;\n}\n\nconsole.log(total);\n```\n\nCheck https://streams.spec.whatwg.org/#rs-class-definition and https://streams.spec.whatwg.org/#rs-asynciterator for further explanation on `ReadableStreamIteratorOptions`.\n\n#### `fromAnyIterable`\n\nPath:\n\n```\n@sec-ant/readable-stream/ponyfill/fromAnyIterable\n```\n\nExample:\n\n```ts\nimport { fromAnyIterable } from \"@sec-ant/readable-stream/ponyfill/fromAnyIterable\";\n\nconst readableStream = fromAnyIterable([\"a\", \"b\"]);\n```\n\n#### All-in-One\n\nPath:\n\n```\n@sec-ant/readable-stream/ponyfill\n```\n\nExample:\n\n```ts\nimport {\n  fromAnyIterable,\n  asyncIterator,\n  type ReadableStreamIteratorOptions,\n} from \"@sec-ant/readable-stream/ponyfill\";\n```\n\n### Polyfill\n\nThis package can be imported as a drop-in _polyfill_ with side effects.\n\n#### `ReadableStream.prototype[Symbol.asyncIterator]` and `ReadableStream.prototype.values`\n\nPath:\n\n```\n@sec-ant/readable-stream/polyfill/asyncIterator\n```\n\nExample:\n\n```ts\nimport \"@sec-ant/readable-stream/polyfill/asyncIterator\";\n\nconst readableStream = (await fetch(\"https://www.example.org/\")).body;\n\nlet total = 0;\nfor await (const chunk of readableStream) {\n  total += chunk.length;\n}\n\nconsole.log(total);\n```\n\n#### `ReadableStream.from`\n\nPath:\n\n```\n@sec-ant/readable-stream/polyfill/fromAnyIterable\n```\n\nExample:\n\n```js\nimport \"@sec-ant/readable-stream/polyfill/fromAnyIterable\";\n\nconst readableStream = ReadableStream.from([\"a\", \"b\"]);\n```\n\nNote that `ReadableStream.from` is not typed because [declared vars cannot be overridden](https://github.com/microsoft/TypeScript/issues/36146).\n\n#### All-in-One\n\nPath:\n\n```\n@sec-ant/readable-stream/polyfill\n```\n\nExample:\n\n```ts\nimport \"@sec-ant/readable-stream/polyfill\";\n```\n\n### Ponyfill + Polyfill\n\n#### `asyncIterator`\n\nPath:\n\n```\n@sec-ant/readable-stream/asyncIterator\n```\n\nExample:\n\n```ts\nimport {\n  asyncIterator,\n  type ReadableStreamIteratorOptions,\n} from \"@sec-ant/readable-stream/asyncIterator\";\n// also with side effects\n```\n\n#### `fromAnyIterable`\n\nPath:\n\n```\n@sec-ant/readable-stream/fromAnyIterable\n```\n\nExample:\n\n```ts\nimport { fromAnyIterable } from \"@sec-ant/readable-stream/fromAnyIterable\";\n// also with side effects\n```\n\n#### All-in-One\n\nPath:\n\n```\n@sec-ant/readable-stream\n```\n\nExample:\n\n```ts\nimport {\n  fromAnyIterable,\n  asyncIterator,\n  type ReadableStreamIteratorOptions,\n} from \"@sec-ant/readable-stream\";\n// also with side effects\n```\n\n### Types\n\nYou can also use this package to augment the `ReadableStream` type for async iteration if the runtime already supports it but the type system does not.\n\nPath:\n\n```\n@sec-ant/readable-stream/async-iterator\n```\n\nExample:\n\n```ts\n/// \u003creference types=\"@sec-ant/readable-stream/async-iterator\" /\u003e\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsec-ant%2Freadable-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsec-ant%2Freadable-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsec-ant%2Freadable-stream/lists"}