sinon
Version:
JavaScript test spies, stubs and mocks.
21 lines (15 loc) • 436 B
JavaScript
;
var hasNextTick = typeof process === "object" && typeof process.nextTick === "function";
var hasSetImmediate = typeof setImmediate === "function";
function nextTick(callback) {
setTimeout(callback, 0);
}
if (hasNextTick) {
module.exports = process.nextTick;
}
if (!hasNextTick && hasSetImmediate) {
module.exports = setImmediate;
}
if (!hasNextTick && !hasSetImmediate) {
module.exports = nextTick;
}