Skip to content
Permalink
Browse files
Extract nextTick to own file
  • Loading branch information
mroderick committed Jan 8, 2018
1 parent 5fa0e66 commit 8c1e221cc5bd25341b5ec8f46b7697178b213793
Showing 2 changed files with 21 additions and 14 deletions.
@@ -2,27 +2,14 @@

var extend = require("./util/core/extend");
var functionName = require("./util/core/function-name");
var nextTick = require("./util/core/next-tick");
var valueToString = require("./util/core/value-to-string");

var slice = Array.prototype.slice;
var join = Array.prototype.join;
var useLeftMostCallback = -1;
var useRightMostCallback = -2;

var nextTick = (function () {
if (typeof process === "object" && typeof process.nextTick === "function") {
return process.nextTick;
}

if (typeof setImmediate === "function") {
return setImmediate;
}

return function (callback) {
setTimeout(callback, 0);
};
})();

function getCallback(behavior, args) {
var callArgAt = behavior.callArgAt;

@@ -0,0 +1,20 @@
"use strict";

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

0 comments on commit 8c1e221

Please sign in to comment.