mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
timers: reduce usage of public util
Refs: https://github.com/nodejs/node/issues/26546 PR-URL: https://github.com/nodejs/node/pull/26583 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
4980cc7d9b
commit
7866508482
@ -39,8 +39,11 @@ const {
|
|||||||
initAsyncResource,
|
initAsyncResource,
|
||||||
validateTimerDuration
|
validateTimerDuration
|
||||||
} = require('internal/timers');
|
} = require('internal/timers');
|
||||||
const internalUtil = require('internal/util');
|
const {
|
||||||
const util = require('util');
|
promisify: { custom: customPromisify },
|
||||||
|
deprecate
|
||||||
|
} = require('internal/util');
|
||||||
|
const { inspect } = require('internal/util/inspect');
|
||||||
const { ERR_INVALID_CALLBACK } = require('internal/errors').codes;
|
const { ERR_INVALID_CALLBACK } = require('internal/errors').codes;
|
||||||
|
|
||||||
let debuglog;
|
let debuglog;
|
||||||
@ -249,8 +252,8 @@ function TimersList(expiry, msecs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the linked list only shows the minimal necessary information.
|
// Make sure the linked list only shows the minimal necessary information.
|
||||||
TimersList.prototype[util.inspect.custom] = function(_, options) {
|
TimersList.prototype[inspect.custom] = function(_, options) {
|
||||||
return util.inspect(this, {
|
return inspect(this, {
|
||||||
...options,
|
...options,
|
||||||
// Only inspect one level.
|
// Only inspect one level.
|
||||||
depth: 0,
|
depth: 0,
|
||||||
@ -457,7 +460,7 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
|
|||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout[internalUtil.promisify.custom] = function(after, value) {
|
setTimeout[customPromisify] = function(after, value) {
|
||||||
const args = value !== undefined ? [value] : value;
|
const args = value !== undefined ? [value] : value;
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
active(new Timeout(resolve, after, args, false));
|
active(new Timeout(resolve, after, args, false));
|
||||||
@ -719,7 +722,7 @@ function setImmediate(callback, arg1, arg2, arg3) {
|
|||||||
return new Immediate(callback, args);
|
return new Immediate(callback, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
setImmediate[internalUtil.promisify.custom] = function(value) {
|
setImmediate[customPromisify] = function(value) {
|
||||||
return new Promise((resolve) => new Immediate(resolve, [value]));
|
return new Promise((resolve) => new Immediate(resolve, [value]));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -752,11 +755,11 @@ module.exports = {
|
|||||||
clearImmediate,
|
clearImmediate,
|
||||||
setInterval,
|
setInterval,
|
||||||
clearInterval,
|
clearInterval,
|
||||||
unenroll: util.deprecate(
|
unenroll: deprecate(
|
||||||
unenroll,
|
unenroll,
|
||||||
'timers.unenroll() is deprecated. Please use clearTimeout instead.',
|
'timers.unenroll() is deprecated. Please use clearTimeout instead.',
|
||||||
'DEP0096'),
|
'DEP0096'),
|
||||||
enroll: util.deprecate(
|
enroll: deprecate(
|
||||||
enroll,
|
enroll,
|
||||||
'timers.enroll() is deprecated. Please use setTimeout instead.',
|
'timers.enroll() is deprecated. Please use setTimeout instead.',
|
||||||
'DEP0095')
|
'DEP0095')
|
||||||
|
Loading…
Reference in New Issue
Block a user