Can not detect object

0

I made an API script, in this script has a basic functions well used. I'm currently working on the IntervalsAPI edition:

var interval = {

    intervals: { },

    create: function(name, func, interval) {
        if(this.intervals[name] != null){
            c.e("[IntervalAPI] Interval with name '"+name+"' already exists!");
        }
        else {
            this.intervals[name] = setInterval(func, interval);
            c.t("IntervalAPI", "Interval '"+name+"' created. Total Intervals: " + _.size(this.intervals));
        }
    },

    delete: function(name){
        if(this.intervals[name] != null){
            clearInterval(this.intervals[name]);
            c.ti("IntervalAPI", "Interval '"+name+"' removed.");
        }
        else {
            c.te("IntervalAPI", "Interval '"+name+"' not found.");
        }
    },

    clear: function(){
        _.each(this.intervals, function(v,k){
            clearInterval(v);
            c.t("IntervalAPI", "Interval '"+k+"' removed.");
        });
    }
};

When I run interval.create("teste", function(){ c.l("Is a Console.Log")}, 1000); the message that the interval has been added is usually displayed. But when I try to remove interval.delete("teste"); it says undefined and consequently the message

  

[IntervalAPI] Interval teste not found.

In the interval.intervals you have the object {test: ...} and it is not returning.

    
asked by anonymous 24.01.2017 / 19:42

0 answers