Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Simple function chaining with a timeout (not ES5 compatible)

View chain.js
1 2 3 4 5 6 7 8 9 10 11 12 13
Array.prototype.chain = function chain(delay) {
var tasks = this, pos = 0, delay = delay || 17;
setTimeout(function() {
tasks[pos++]();
if (pos < tasks.length) setTimeout(arguments.callee, delay);
}, delay);
return this;
};
 
// Usage;
var tasks = [];
tasks.push(func);
tasks.chain();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.