Open
Description
What is the problem this feature will solve?
When multiple callers use Readable[Symbol.asyncIterator]
, each caller receives a partial result.
import {Readable} from 'node:stream'
const stream = Readable.from(['a', 'b', 'c'])
const iterate = async (readerName) => {
for await (const chunk of stream) {
console.log(readerName, chunk)
}
}
await Promise.all([
iterate('one'),
iterate('two'),
])
one a
two b
one c
Some callers might expect that result. But others might expect the following result instead.
one a
two a
one b
two b
one c
two c
What is the feature you are proposing to solve the problem?
Adding an option to readable.iterator()
to use readable.on('data')
instead of readable.read()
. This would enable the above behavior.
What alternatives have you considered?
Implementing this user-land.
See an example of it at sindresorhus/get-stream#121
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Awaiting Triage