Skip to content
Browse files

use setImmediate on 0.10

  • Loading branch information...
1 parent 04253f6 commit d5b3bc26c9b9c9c5348a183c538a063f31555c6f @substack committed Mar 25, 2013
Showing with 13 additions and 3 deletions.
  1. +7 −2 index.js
  2. +6 −1 lib/test.js
View
9 index.js
@@ -16,6 +16,11 @@ var onexit = (function () {
return function (cb) { stack.push(cb) };
})();
+var nextTick = typeof setImmediate !== 'undefined'
+ ? setImmediate
+ : process.nextTick
+;
+
exports = module.exports = createHarness();
exports.createHarness = createHarness;
exports.Test = Test;
@@ -71,7 +76,7 @@ function createHarness (conf_) {
});
}
- process.nextTick(function () {
+ nextTick(function () {
if (!out.piped) out.pipe(createDefaultStream());
if (!began) out.begin();
began = true;
@@ -117,7 +122,7 @@ function createHarness (conf_) {
pending.unshift.apply(pending, unshifts);
}
- process.nextTick(function () {
+ nextTick(function () {
running = false;
if (pending.length) return pending.shift()();
if (count === 0 && !closed) {
View
7 lib/test.js
@@ -5,6 +5,11 @@ var path = require('path');
module.exports = Test;
+var nextTick = typeof setImmediate !== 'undefined'
+ ? setImmediate
+ : process.nextTick
+;
+
Test.prototype = new EventEmitter;
function Test (name_, opts_, cb_) {
@@ -137,7 +142,7 @@ Test.prototype._assert = function assert (ok, opts) {
self.emit('result', res);
if (self._plan === self.assertCount) {
- process.nextTick(function () {
+ nextTick(function () {
if (!self.ended) self.end();
});
}

0 comments on commit d5b3bc2

Please sign in to comment.
Something went wrong with that request. Please try again.