Allow multiple readers to iterate over a stream at the same time
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
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 https://github.com/sindresorhus/get-stream/pull/121
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in lib/internal/streams/readable.js bei Readable[Symbol.asyncIterator] und untersuche, wie readable.iterator() den Stream derzeit konsumiert. Vergleiche das vorgeschlagene data-event-Verhalten mit dem bereitgestellten Beispiel für gleichzeitige Iteration; abgeschlossen bedeutet, dass eine Option definiert ist und mehrere Leser jeden Chunk wie dokumentiert erhalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- api, backend
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100