I detest the way setInterval() looks, so I came up with this... have been
using it my personal JS for some time.

Object.extend(Function.prototype, {
  repeat: function() {
    var __method = this, args = $A(arguments), interval = args.shift() *
    return window.setInterval(function() {
      return __method.apply(__method, args);
    }, interval );

// usage:
var _pollInt = 0;
function repetiousPollFn() {


Will, of course, repeat repetiousPollFn() every half second.

Almost identical to .delay(), except that it returns setInterval instead of
setTimeout. One thing I intend to add is support for clearInterval, however
I figured I'd at least bring it up here first. I've never
proposed/contributed here before (i'm a lurker of the list :D ) - any
guidance is appreciated.


You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to