root / HServer / 00.Server / 00.Program / node_modules / process-nextick-args / index.js
이력 | 보기 | 이력해설 | 다운로드 (1.02 KB)
| 1 |
'use strict';
|
|---|---|
| 2 |
|
| 3 |
if (!process.version ||
|
| 4 |
process.version.indexOf('v0.') === 0 || |
| 5 |
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { |
| 6 |
module.exports = { nextTick: nextTick };
|
| 7 |
} else {
|
| 8 |
module.exports = process |
| 9 |
} |
| 10 |
|
| 11 |
function nextTick(fn, arg1, arg2, arg3) { |
| 12 |
if (typeof fn !== 'function') { |
| 13 |
throw new TypeError('"callback" argument must be a function'); |
| 14 |
} |
| 15 |
var len = arguments.length; |
| 16 |
var args, i;
|
| 17 |
switch (len) {
|
| 18 |
case 0: |
| 19 |
case 1: |
| 20 |
return process.nextTick(fn);
|
| 21 |
case 2: |
| 22 |
return process.nextTick(function afterTickOne() { |
| 23 |
fn.call(null, arg1);
|
| 24 |
}); |
| 25 |
case 3: |
| 26 |
return process.nextTick(function afterTickTwo() { |
| 27 |
fn.call(null, arg1, arg2);
|
| 28 |
}); |
| 29 |
case 4: |
| 30 |
return process.nextTick(function afterTickThree() { |
| 31 |
fn.call(null, arg1, arg2, arg3);
|
| 32 |
}); |
| 33 |
default:
|
| 34 |
args = new Array(len - 1); |
| 35 |
i = 0;
|
| 36 |
while (i < args.length) {
|
| 37 |
args[i++] = arguments[i];
|
| 38 |
} |
| 39 |
return process.nextTick(function afterTick() { |
| 40 |
fn.apply(null, args);
|
| 41 |
}); |
| 42 |
} |
| 43 |
} |
| 44 |
|