mirror of https://gitee.com/openkylin/nodejs.git
14 lines
240 B
JavaScript
14 lines
240 B
JavaScript
![]() |
'use strict';
|
||
|
require('../common');
|
||
|
|
||
|
module.exports = function tick(x, cb) {
|
||
|
function ontick() {
|
||
|
if (--x === 0) {
|
||
|
if (typeof cb === 'function') cb();
|
||
|
} else {
|
||
|
setImmediate(ontick);
|
||
|
}
|
||
|
}
|
||
|
setImmediate(ontick);
|
||
|
};
|