Skip to content

Instantly share code, notes, and snippets.

@tankala
Created February 11, 2019 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tankala/949fbbfb10aa21a8bc5d5cacfd3bfa7f to your computer and use it in GitHub Desktop.
Save tankala/949fbbfb10aa21a8bc5d5cacfd3bfa7f to your computer and use it in GitHub Desktop.
Async Queue Example
const async = require('async');
var processQueue = function (message, callback) {
setTimeout(function() {
console.log(`Task ${message} completed`);
callback();
}, 500);
}
var queue = async.queue(processQueue, 3);
queue.drain = function() {
console.log('Yuppie all tasks completed');
}
var processTasks = function () {
for (let index = 1; index <= 10; index++) {
queue.push(index);
}
}
processTasks();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment