This method allows iterating a stream. For each chunk in the stream the fn function will be called.
If the fn function returns a promise - that promise will be awaited.
This method is different from for await...of loops in that it can optionally process chunks concurrently.
In addition, a forEach iteration can only be stopped by having passed a signal option
and aborting the related AbortController while for await...of can be stopped with break or return.
In either case the stream will be destroyed.
This method is different from listening to the 'data' event in that it uses the readable event
in the underlying machinary and can limit the number of concurrent fn calls.
This method allows iterating a stream. For each chunk in the stream the fn function will be called. If the fn function returns a promise - that promise will be
await
ed.This method is different from
for await...of
loops in that it can optionally process chunks concurrently. In addition, aforEach
iteration can only be stopped by having passed asignal
option and aborting the related AbortController whilefor await...of
can be stopped withbreak
orreturn
. In either case the stream will be destroyed.This method is different from listening to the
'data'
event in that it uses thereadable
event in the underlying machinary and can limit the number of concurrent fn calls.