sinon-dist
Advanced tools
Comparing version 0.7.1 to 0.7.2
{ | ||
"name": "sinon-dist", | ||
"description": "Standalone builds of Sinon.js", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"homepage": "https://github.com/CodeYellowBV/sinon-dist#readme", | ||
@@ -6,0 +6,0 @@ "main": "sinon.js", |
68
sinon.js
/** | ||
* Sinon.JS 0.7.1, 2010/10/16 | ||
* Sinon.JS 0.7.2, 2010/10/25 | ||
* | ||
@@ -1068,2 +1068,36 @@ * @author Christian Johansen (christian@cjohansen.no) | ||
function callbacksInRange(timeouts, from, to) { | ||
var found, timer, tmp, i, l, timers = [], timeoutsCopy = {}; | ||
for (var prop in timeouts) { | ||
timeoutsCopy[prop] = timeouts[prop]; | ||
} | ||
while (timeoutsCopy && found !== 0) { | ||
found = 0; | ||
tmp = timersInRange(timeoutsCopy, from, to); | ||
for (i = 0, l = tmp.length; i < l; i++) { | ||
timer = tmp[i]; | ||
// Push a copy onto the call stack | ||
timers.push({ | ||
func: timer.func, | ||
callAt: timer.callAt, | ||
interval: timer.interval, | ||
id: timer.id | ||
}); | ||
if (typeof timer.interval == "number") { | ||
found += 1; | ||
timer.callAt += timer.interval; | ||
} else { | ||
delete timeoutsCopy[timer.id]; | ||
} | ||
} | ||
} | ||
return timers; | ||
} | ||
function parseTime(str) { | ||
@@ -1145,31 +1179,5 @@ if (!str) { | ||
ms = typeof ms == "number" ? ms : parseTime(ms); | ||
var found, timer, prop, i, l; | ||
var tickFrom = this.now, tickTo = this.now + ms; | ||
var tmp, timers = []; | ||
while (this.timeouts && found !== 0) { | ||
found = 0; | ||
tmp = timersInRange(this.timeouts, tickFrom, tickTo); | ||
for (i = 0, l = tmp.length; i < l; i++) { | ||
timer = tmp[i]; | ||
// Push a copy onto the call stack | ||
timers.push({ | ||
func: timer.func, | ||
callAt: timer.callAt, | ||
interval: timer.interval, | ||
id: timer.id | ||
}); | ||
if (typeof timer.interval == "number") { | ||
found += 1; | ||
timer.callAt += timer.interval; | ||
} else { | ||
delete this.timeouts[prop]; | ||
} | ||
} | ||
} | ||
timers = timers.sort(function (a, b) { | ||
var timers = callbacksInRange(this.timeouts, tickFrom, tickTo).sort(function (a, b) { | ||
return a.callAt < b.callAt ? -1 : (a.callAt > b.callAt ? 1 : 0); | ||
@@ -1949,2 +1957,6 @@ }); | ||
return obj; | ||
}, | ||
create: function () { | ||
return sinon.create(sinon.sandbox); | ||
} | ||
@@ -1951,0 +1963,0 @@ }); |
61578
1915