mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
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);
|
||
|
};
|