I would assume when reading the chunks, it would start with 'applesauce'
, 'blueberry'
, etc. but instead the iterable that was used to initially create the stream is always last rather than first, despite the pushes being in the correct order. Can someone explain why the order is the way it is?
import stream from 'node:stream';
const a = stream.Readable.from(['applesauce', 'blueberry', 'muffins']);
a.push('one');
a.push('two');
a.push('three');
a.push('333');
a.push('555');
a.push('777');
for await (const chunk of a) {
console.log(chunk);
}
Prints:
one
two
three
333
555
777
applesauce
blueberry
muffins