Skip to content

Instantly share code, notes, and snippets.

@Havvy
Created December 27, 2014 08:00
Show Gist options
  • Select an option

  • Save Havvy/dbc20c0d4a37b53d3df4 to your computer and use it in GitHub Desktop.

Select an option

Save Havvy/dbc20c0d4a37b53d3df4 to your computer and use it in GitHub Desktop.
var forEachDelayed = function recur (array, fn, delay, ix) {
ix = (typeof ix === "number") ? ix : 0;
fn(array[ix], ix, array);
if (ix === array.length - 1) { return; }
setTimeout(function () {
recur(array, fn, delay, ix + 1);
}, delay);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment