each-stream
v1.0.4
Published
Iterate stream with async and concurrency support.
Downloads
57
Maintainers
Readme
each-stream
Iterate stream with async and concurrency support.
Install
$ npm install each-stream --save
Usage
const each = require('each-stream')
const stream = await db.users.find({}, { stream: true })
await each(stream, async user => {
const stats = await stats.retrieve(user.id)
return sendEmail(user.id, stats)
}, { concurrency: 10 })
API
each(stream, fn, [options])
stream
Required
Type: object
The Readable stream to iterate.
fn
Required
Type: function
The async function to invoke per every iteration.
options
concurrency
Type: number
Default: Number.MAX_SAFE_INTEGER
The maximum concurrency allowed.
waiting
Type: number
Default: 100
The quantity of time to wait until check if concurrency changed.
License
each-stream © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats