Skip to content

Instantly share code, notes, and snippets.

@serby
Created April 17, 2013 09:33
Show Gist options
  • Select an option

  • Save serby/5403020 to your computer and use it in GitHub Desktop.

Select an option

Save serby/5403020 to your computer and use it in GitHub Desktop.
var q = []
function (req, res) {
q.push(function (cb) {
resize(req.body, function(error, complete) {
res.send(complete)
cb()
})
})
}
function next() {
process.nextTick(function () {
if (q.length > 0) {
var work = q.pop()
work(next)
}
})
}
next()
next()
next()
next()
///
var q = async.queue(function (fn, callback) {
fn(callback)
}, 6)
// assign a callback
q.drain = function() {
console.log('all items have been processed');
}
function (req, res) {
q.push(function (cb) {
resize(req.body, function(error, complete) {
res.send(complete)
cb()
})
})
}
q.push({name: 'foo'}, function (err) {
console.log('finished processing foo');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment