Repository navigation
Streams: support ReadableStream.from() #48389
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.web streamsIssues and PRs related to the Web Streams API.Issues and PRs related to the Web Streams API.
Description
Activity
This is very similar to Node's
Readable.from(iterable), except for Web Streams. And because bothReadableandReadableStreamare async iterables and have a staticfrom()method, there's a nice duality for converting them:import { Readable } from 'node:stream'; import { ReadableStream } from 'node:stream/web'; const nodeReadable = new Readable({ /* ... */ }); const webReadableStreamFromNodeReadable = ReadableStream.from(nodeReadable); const webReadableStream = new ReadableStream({ /* ... */ }); const nodeReadableFromWebReadableStream = Readable.from(webReadableStream);
Also,
Readable.toWeb(nodeReadable)will be equivalent toReadableStream.from(nodeReadable)(although the former can be optimized specifically for Node streams, whereas the latter is more general).- addedweb streamsIssues and PRs related to the Web Streams API.Issues and PRs related to the Web Streams API.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Jun 8, 2023 Hey! will give this a try hoping to have a PR ready soon!
Reacted by Mattias Buelens- added a commit that references this issue
on Jul 18, 2023 - added 2 commits that reference this issue
on Aug 14, 2023 - added a commit that references this issue
on Aug 14, 2023 - added a commit that references this issue
on Aug 15, 2023
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.web streamsIssues and PRs related to the Web Streams API.Issues and PRs related to the Web Streams API.
The Streams standard has been updated with a new utility method
ReadableStream.from(asyncIterable), which adapts any sync or async iterable into aReadableStream.Specification: https://streams.spec.whatwg.org/#rs-from
Spec change: whatwg/streams#1083
WPT tests: web-platform-tests/wpt#27009