Skip to content

Instantly share code, notes, and snippets.

@raphael-brand
Created January 13, 2016 20:36
Show Gist options
  • Save raphael-brand/0a8846c0ac9453b1c172 to your computer and use it in GitHub Desktop.
Save raphael-brand/0a8846c0ac9453b1c172 to your computer and use it in GitHub Desktop.
jQuery.extend({
repeat : function(times, callback) {
var t = parseInt(times) | 0, i = 0;
if (t <= 0)
return console.warn('repeat() 1st argument expects unsigned int greater than 0 .');
if (typeof (callback) != 'function')
return console.warn('repeat() 2nd argument expects function');
var x = t;
while (x > i)callback(i++);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment