Browse Source

fix simcal exhaustion if not within limit

Herbert Vojčík 8 years ago
parent
commit
0984534af2
1 changed files with 3 additions and 2 deletions
  1. 3 2
      lib/usim.js

+ 3 - 2
lib/usim.js

@@ -27,10 +27,11 @@
     var sentinel = {time: -Infinity, object: null};
 
     uSim.prototype.peekUntil = function (limit, cb) {
-        var record = this.simcal.shift() || sentinel,
+        var record = this.simcal[0] || sentinel,
             recordTime = record.time;
         if (recordTime > limit) record = sentinel;
-        else if (recordTime > this.time) this.time = recordTime;
+        else this.simcal.shift();
+        if (recordTime > this.time) this.time = recordTime;
         if (cb) cb(record.object); else return record.object;
     };