Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created August 18, 2014 23:55
Show Gist options
  • Save mafintosh/672fcb9e0568ae9d639c to your computer and use it in GitHub Desktop.
Save mafintosh/672fcb9e0568ae9d639c to your computer and use it in GitHub Desktop.
var once = require('once')
var concurrent = 10
var pending = 0
through(function(data, enc, cb) {
cb = once(cb)
pending++
if (pending < concurrent) cb()
rr().write(data, function(err) {
if (err) return cb(err)
pending--
cb()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment