Skip to content

Instantly share code, notes, and snippets.

@christianschmizz
Created October 21, 2011 07:42
Show Gist options
  • Save christianschmizz/1303310 to your computer and use it in GitHub Desktop.
Save christianschmizz/1303310 to your computer and use it in GitHub Desktop.
Build and process the queue
var i = 0, queue = [];
// Put some functions at the queue
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); });
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); });
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); });
queue.push(function(data, next) { console.log(++i, data); setTimeout(next, 1000); });
process(queue, {
stopCallback: function(data) { console.log('stop callback', data); }, // optional
callback: function(data) { console.log('callback', data); }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment