Open this example in the interactive library
Source code
const source = () =>
new ReadableStream({
start(c) {
c.enqueue("a");
c.enqueue("b");
c.close();
},
});
console.log(
await Promise.all(
source()
.tee()
.map((branch) => Array.fromAsync(branch)),
),
);
Sample output
[ [ 'a', 'b' ], [ 'a', 'b' ] ]
