lib: refactor to use validateFunction

add validateFunction and refactor to use validateFunction

PR-URL: https://github.com/nodejs/node/pull/37045
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
ZiJian Liu 2021-01-24 15:46:24 +08:00 committed by Benjamin Gruenbaum
parent 8c3cdce418
commit 064a7070c7
15 changed files with 79 additions and 79 deletions

View file

@ -68,7 +68,10 @@ const {
kHandle,
} = require('internal/histogram');
const { validateCallback } = require('internal/validators');
const {
validateCallback,
validateFunction,
} = require('internal/validators');
const { setImmediate } = require('timers');
const kCallback = Symbol('callback');
@ -463,9 +466,7 @@ class Performance {
}
timerify(fn) {
if (typeof fn !== 'function') {
throw new ERR_INVALID_ARG_TYPE('fn', 'Function', fn);
}
validateFunction(fn, 'fn');
if (fn[kTimerified])
return fn[kTimerified];
const ret = timerify(fn, fn.length);