oven-sh/bun

Support `ReadableStream.from()`

Fechada

#3.700 aberto em 20 de jul. de 2023

 (9 comentários) (11 reações) (0 responsável)Rust (4.486 forks)batch import
enhancementgood first issueweb-api

Métricas do repositório

Stars
 (90.348 estrelas)
Métricas de merge de PR
 (Mesclagem média 1d 17h) (357 fundiu PRs em 30d)

Description

What is the problem this feature would solve?

Creating a ReadableStream from an array (or any other iterable) requires a lot of boilerplate, as can be seen in these tests and this example.

What is the feature you are proposing to solve the problem?

The Streams standard now has a new utility method ReadableStream.from(asyncIterable), which adapts any sync or async iterable into a ReadableStream. Once Bun supports this method, creating a ReadableStream from an array would become a one-liner.

Specification: https://streams.spec.whatwg.org/#rs-from Spec change: https://github.com/whatwg/streams/pull/1083 WPT tests: https://github.com/web-platform-tests/wpt/pull/27009

Deno and Node.js also recently implemented this new method, see https://github.com/denoland/deno/pull/19446 and https://github.com/nodejs/node/pull/48395.

Since Bun is powered by JavaScriptCore, you may also want to look into their pull request: https://github.com/WebKit/WebKit/pull/12454

What alternatives have you considered?

No response

Guia do colaborador