|
@@ -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;
|
|
|
};
|
|
|
|