How can chunks be allocated in a node.js stream in object mode all at once?
Posted
by
Quentin Engles
on Stack Overflow
See other posts from Stack Overflow
or by Quentin Engles
Published on 2014-06-04T00:47:35Z
Indexed on
2014/06/04
3:25 UTC
Read the original article
Hit count: 189
I can see how buffers, and strings can be sent as chunks, but I'm having a problem thinking about how streams can be dealt when working in object mode.
Say I have a byte stream from an http request message. I want to take that message, parse, and then transform it into one big object.
I already know how to parse the message. What I'm wondering is if the message is big so it has many chunks, but I want to make one object for the output how can I make sure the data event waits for the whole thing?
Is this just a matter of not using the push method until the chunked data has finished being sent?
That would then restrict the stream data output to a smaller object which I think I'm fine with for now.
As an added condition the larger data will be reduced in size after the the transform.
© Stack Overflow or respective owner