Skip to content

Commit ebb0c2a

Browse files
joyeecheungtargos
authored andcommitted
timers: reduce usage of public util
Refs: #26546 PR-URL: #26583 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent e6367c2 commit ebb0c2a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/timers.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ const {
3939
initAsyncResource,
4040
validateTimerDuration
4141
} = require('internal/timers');
42-
const internalUtil = require('internal/util');
43-
const util = require('util');
42+
const {
43+
promisify: { custom: customPromisify },
44+
deprecate
45+
} = require('internal/util');
46+
const { inspect } = require('internal/util/inspect');
4447
const { ERR_INVALID_CALLBACK } = require('internal/errors').codes;
4548

4649
let debuglog;
@@ -249,8 +252,8 @@ function TimersList(expiry, msecs) {
249252
}
250253

251254
// Make sure the linked list only shows the minimal necessary information.
252-
TimersList.prototype[util.inspect.custom] = function(_, options) {
253-
return util.inspect(this, {
255+
TimersList.prototype[inspect.custom] = function(_, options) {
256+
return inspect(this, {
254257
...options,
255258
// Only inspect one level.
256259
depth: 0,
@@ -457,7 +460,7 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
457460
return timeout;
458461
}
459462

460-
setTimeout[internalUtil.promisify.custom] = function(after, value) {
463+
setTimeout[customPromisify] = function(after, value) {
461464
const args = value !== undefined ? [value] : value;
462465
return new Promise((resolve) => {
463466
active(new Timeout(resolve, after, args, false));
@@ -719,7 +722,7 @@ function setImmediate(callback, arg1, arg2, arg3) {
719722
return new Immediate(callback, args);
720723
}
721724

722-
setImmediate[internalUtil.promisify.custom] = function(value) {
725+
setImmediate[customPromisify] = function(value) {
723726
return new Promise((resolve) => new Immediate(resolve, [value]));
724727
};
725728

@@ -752,11 +755,11 @@ module.exports = {
752755
clearImmediate,
753756
setInterval,
754757
clearInterval,
755-
unenroll: util.deprecate(
758+
unenroll: deprecate(
756759
unenroll,
757760
'timers.unenroll() is deprecated. Please use clearTimeout instead.',
758761
'DEP0096'),
759-
enroll: util.deprecate(
762+
enroll: deprecate(
760763
enroll,
761764
'timers.enroll() is deprecated. Please use setTimeout instead.',
762765
'DEP0095')

0 commit comments

Comments
 (0)