瀏覽代碼

fix simcal exhaustion if not within limit

Herbert Vojčík 8 年之前
父節點
當前提交
0984534af2
共有 1 個文件被更改,包括 3 次插入2 次删除
  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;
     };