Created
August 18, 2014 23:55
-
-
Save mafintosh/672fcb9e0568ae9d639c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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