Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created February 4, 2011 00:01
Show Gist options
  • Save cloudhead/810487 to your computer and use it in GitHub Desktop.
Save cloudhead/810487 to your computer and use it in GitHub Desktop.
function process(items, callback) {
(function iterate(list) {
var item = list.shift();
if (item) {
process.nextTick(function () {
iterate(list);
});
} else {
callback('done!');
}
})(items.slice(0));
}
process(array, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment