Skip to content

Commit

Permalink
timers: reduce usage of public util
Browse files Browse the repository at this point in the history
Refs: #26546

PR-URL: #26583
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
joyeecheung authored and targos committed Mar 27, 2019
1 parent e6367c2 commit ebb0c2a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ const {
initAsyncResource,
validateTimerDuration
} = require('internal/timers');
const internalUtil = require('internal/util');
const util = require('util');
const {
promisify: { custom: customPromisify },
deprecate
} = require('internal/util');
const { inspect } = require('internal/util/inspect');
const { ERR_INVALID_CALLBACK } = require('internal/errors').codes;

let debuglog;
Expand Down Expand Up @@ -249,8 +252,8 @@ function TimersList(expiry, msecs) {
}

// Make sure the linked list only shows the minimal necessary information.
TimersList.prototype[util.inspect.custom] = function(_, options) {
return util.inspect(this, {
TimersList.prototype[inspect.custom] = function(_, options) {
return inspect(this, {
...options,
// Only inspect one level.
depth: 0,
Expand Down Expand Up @@ -457,7 +460,7 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
return timeout;
}

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

setImmediate[internalUtil.promisify.custom] = function(value) {
setImmediate[customPromisify] = function(value) {
return new Promise((resolve) => new Immediate(resolve, [value]));
};

Expand Down Expand Up @@ -752,11 +755,11 @@ module.exports = {
clearImmediate,
setInterval,
clearInterval,
unenroll: util.deprecate(
unenroll: deprecate(
unenroll,
'timers.unenroll() is deprecated. Please use clearTimeout instead.',
'DEP0096'),
enroll: util.deprecate(
enroll: deprecate(
enroll,
'timers.enroll() is deprecated. Please use setTimeout instead.',
'DEP0095')
Expand Down

0 comments on commit ebb0c2a

Please sign in to comment.