/* @flow */

/*
 timer.set("tid", "2015/1/29 0:48:00", "fuga",
 "Quest", {party: 2}, function (a) {console.log(a);});
 timer.set("tid", "2015/1/29 0:48:00", "hoge",
 "Quest", {party: 3}, function (a) {console.log(a);});
 timer.cancel("Quest", function (i) {
 return i.party === 3;
 });
 */

var timer = timer || {};

(function () {
    var INTERVAL = 1000,
        timers = [];

    function Timer() {
    }

    Timer.prototype.set = function (param) {
        timers.push(param);
        console.log('timer/set');
        console.dir(timers);
    };


    // cancel :: (param -> bool) -> ()
    Timer.prototype.cancel = function (f) {
        console.log('timer/cancel');
        var i, l = timers.length;
        for (i = 0; i < l; i++) {
            if(f(timers[i])) {
                timers.splice(i, 1);
                return this;
            }
        }
        console.log('Non-existed timer');
        return this;
    };

    timer = new Timer();

    function tick() {
        var now = new Date(),
            i,
            l = timers.length;
        for (i = 0; i < l; i++) {
            if (timers[i].date < now) {
                timers[i].callback(timers[i]);
                timers.splice(i, 1);
                break;
            }
        }
        setTimeout(tick, INTERVAL);
    }

    tick();

}());

@@ -300,22 +300,8 @@
 r = 
-timer %7C%7C %7B%7D;%0A%0A
 (fun
@@ -330,17 +330,17 @@
 ERVAL = 
-1
+5
 000,%0A   
@@ -377,24 +377,46 @@
 n Timer() %7B%0A
+        this.start();%0A
     %7D%0A%0A    T
@@ -943,33 +943,193 @@
     
-t
+T
 imer
- = new Timer();%0A%0A   
+.prototype.start = function () %7B%0A        var self = this;%0A        window.setInterval(function () %7B%0A            self.tick();%0A        %7D, INTERVAL);%0A    %7D;%0A%0A    Timer.prototype.tick =
  fun
@@ -1133,21 +1133,16 @@
 function
- tick
 () %7B%0A   
@@ -1427,60 +1427,36 @@
     
+%7D;%0A%0A
     
-setTimeout(tick, INTERVAL);%0A    %7D%0A%0A    tick
+return new Timer
 ();%0A
-%0A
 %7D())

Clean up timer.js