Should transform streams with async generators return return all values concatenated #4758
Replies: 0 comments 1 reply
-
Your understanding is correct, and the behavior you're seeing is due to the way you've implemented the stream processing in your code. In your code, you're using the Here's the key part of your transform stream implementation: const t = new Transform({
transform(chunk, encoding, callback) {
callback(null, chunk?.toString().toUpperCase());
},
}); In this implementation, you're transforming each chunk to its uppercase representation and then passing it to the callback. This effectively combines the chunks together, as you're pushing the combined, uppercase chunk downstream. To achieve the output you expect ( const t = new Transform({
transform(chunk, encoding, callback) {
const upperCaseChunk = chunk?.toString().toUpperCase();
for (const char of upperCaseChunk) {
callback(null, char);
}
},
}); With this change, each character will be emitted individually by the transform stream, and your output will be |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Take the example of the following code:
The output of the following is
But I expect the output to be
['A','B','C']
, I not sure if this is an issue or flaw in my understanding hence asking here if anyone can guide it would be very helpful!Beta Was this translation helpful? Give feedback.
All reactions