- From: James M Snell <notifications@github.com>
- Date: Sat, 23 Mar 2024 14:03:30 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 23 March 2024 21:03:34 UTC
### What problem are you trying to solve? Today, writing multiple values at once to a `WritableStream` is not generally possible or efficient. Each individual call to `write(...)` assumes a single value, with a single promise returned per value. ### What solutions exist today? Node.js `stream.Writable` offers both `write(...)` and `writev(...)` options. The `write(...)` takes a single value while `writev(...)` takes multiple. ### How would you solve it? Introduce a new `writev(...)` method to `WritableStreamDefaultWriter` (or something similar) So instead of something like... ``` const writable = getWritableStreamSomehow(); const writer = writable.getWriter(); await Promise.all([ writer.write('hello'), writer.write('world'), writer.write('!!!'), ]); // Creates at least four promises... ``` We could simply (and efficiently do) ```js const writable = getWritableStreamSomehow(); const writer = writable.getWriter(); await writer.writev(['hello', 'world', '!!!']); // Creates only one promise ``` The `writev(...)` method would accept any iterable or async-iterable as the input. ### Anything else? _No response_ -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/1309 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/issues/1309@github.com>
Received on Saturday, 23 March 2024 21:03:34 UTC