>
> Classical `each` concept doesn't works in async world, this loop for
> example won't
> wait when operation of inserting chunk into database will be successfully
> (or not) finished.
>
> It will consume memory if for example stream is big and fast and database
> it written to slow.
>

If you want to apply backpressure simply return false from the forEach
iterator function.

If you want to catch errors simply `this.emit("error")` as `this` in the
callback is the writable stream.

forEach is the same as `stream.pipe(WriteStream(iterator))`


> Same with toArray - it will load all data into memory.
>

When you call toArray you want to load the entire thing into memory. That's
a choice.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to