process
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -6,3 +6,17 @@ // shim for using process in browser | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
@@ -12,4 +26,5 @@ if (draining) { | ||
} | ||
var timeout = setTimeout(cleanUpNextTick); | ||
draining = true; | ||
var currentQueue; | ||
var len = queue.length; | ||
@@ -19,12 +34,21 @@ while(len) { | ||
queue = []; | ||
var i = -1; | ||
while (++i < len) { | ||
currentQueue[i](); | ||
while (++queueIndex < len) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
clearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
queue.push(fun); | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (!draining) { | ||
@@ -35,2 +59,10 @@ setTimeout(drainQueue, 0); | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
@@ -37,0 +69,0 @@ process.browser = true; |
@@ -8,3 +8,6 @@ { | ||
], | ||
"version": "0.10.1", | ||
"scripts": { | ||
"test": "mocha test.js" | ||
}, | ||
"version": "0.11.0", | ||
"repository": { | ||
@@ -18,3 +21,6 @@ "type": "git", | ||
"node": ">= 0.6.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "2.2.1" | ||
} | ||
} |
@@ -14,2 +14,3 @@ # process | ||
* [hrtime](https://github.com/kumavis/browser-process-hrtime) | ||
* [stdout](https://github.com/kumavis/browser-stdout) | ||
@@ -16,0 +17,0 @@ ## package manager notes |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
7058
6
144
1
25
1