Explorar o código

fix simcal exhaustion if not within limit

Herbert Vojčík %!s(int64=8) %!d(string=hai) anos
pai
achega
0984534af2
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  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;
     };