Skip to content

Instantly share code, notes, and snippets.

@HenrikJoreteg
Created July 7, 2010 18:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HenrikJoreteg/467030 to your computer and use it in GitHub Desktop.
Save HenrikJoreteg/467030 to your computer and use it in GitHub Desktop.
Simple function queue runner. Just pass me an array of functions and I'll execute them one by one at the given interval.
// Simple function queue runner. Just pass me an array of functions and I'll
// execute them one by one at the given interval.
run_queue = function (funcs, step, speed) {
step = step || 0;
speed = speed || 500;
funcs = funcs || [];
if (step < funcs.length) {
// execute function
funcs[step]();
// loop it
setTimeout(function () {
run_queue(funcs, step + 1, speed);
}, speed);
}
return;
};
@scottferg
Copy link

Wooo I like this

@HenrikJoreteg
Copy link
Author

Cool, glad it's useful for someone else too.

@juliomenendez
Copy link

Nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment