Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Simple function chaining with a timeout (not ES5 compatible)
Array.prototype.chain = function chain(delay) {
var tasks = this, pos = 0, delay = delay || 17;
setTimeout(function() {
if (pos < tasks.length) setTimeout(arguments.callee, delay);
}, delay);
return this;
// Usage;
var tasks = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment