lib: refactor to use validateCallback

PR-URL: https://github.com/nodejs/node/pull/36609
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
ZiJian Liu 2020-12-23 19:22:00 +08:00 committed by Node.js GitHub Bot
parent 8cf5ae07e9
commit b00bb01db9
20 changed files with 114 additions and 125 deletions

View file

@ -56,7 +56,6 @@ const L = require('internal/linkedlist');
const kInspect = require('internal/util').customInspectSymbol;
const {
ERR_INVALID_CALLBACK,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_ARG_VALUE,
ERR_VALID_PERFORMANCE_ENTRY_TYPE,
@ -68,6 +67,8 @@ const {
kHandle,
} = require('internal/histogram');
const { validateCallback } = require('internal/validators');
const { setImmediate } = require('timers');
const kCallback = Symbol('callback');
const kTypes = Symbol('types');
@ -341,9 +342,7 @@ class PerformanceObserverEntryList {
class PerformanceObserver {
constructor(callback) {
if (typeof callback !== 'function') {
throw new ERR_INVALID_CALLBACK(callback);
}
validateCallback(callback);
ObjectDefineProperties(this, {
[kTypes]: {
enumerable: false,