Skip to content

Instantly share code, notes, and snippets.

@drhayes
Created January 15, 2013 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drhayes/4536848 to your computer and use it in GitHub Desktop.
Save drhayes/4536848 to your computer and use it in GitHub Desktop.
EventChain's repeat method
update.repeat = function(times) {
times = times || Infinity;
var originalTimes = times;
var stepsCopy;
steps.push(function() {
times -= 1;
if (times > 0) {
var args = stepsCopy.slice(0);
args.unshift(1, 0);
[].splice.apply(steps, args);
} else {
// For successive repeats.
times = originalTimes;
}
// End.
steps.shift();
});
stepsCopy = steps.slice(0);
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment