-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Open
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.never-staleMark issue so that it is never considered staleMark issue so that it is never considered stalestreamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
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
sindresorhus and florianbepunkt
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.never-staleMark issue so that it is never considered staleMark issue so that it is never considered stalestreamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Type
Projects
Status
Awaiting Triage