From 0defe4effa82824ea340158d45e53cb57f940cbd Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Thu, 19 Jan 2023 18:08:38 +0900 Subject: [PATCH] trace_events: refactor to use `validateStringArray` `options.categories` is string[]. So used `validateStringArray` Refs: https://nodejs.org/dist/latest-v19.x/docs/api/tracing.html#trace_eventscreatetracingoptions PR-URL: https://github.com/nodejs/node/pull/46012 Reviewed-By: Luigi Pinca --- lib/trace_events.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/trace_events.js b/lib/trace_events.js index 5211f8b0b1fc74..672095cec41a30 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -1,7 +1,6 @@ 'use strict'; const { - ArrayIsArray, ArrayPrototypeJoin, SafeSet, Symbol, @@ -17,7 +16,6 @@ const kMaxTracingCount = 10; const { ERR_TRACE_EVENTS_CATEGORY_REQUIRED, ERR_TRACE_EVENTS_UNAVAILABLE, - ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; const { ownsProcessState } = require('internal/worker'); @@ -29,6 +27,7 @@ const { customInspectSymbol } = require('internal/util'); const { format } = require('internal/util/inspect'); const { validateObject, + validateStringArray, } = require('internal/validators'); const enabledTracingObjects = new SafeSet(); @@ -84,11 +83,7 @@ class Tracing { function createTracing(options) { validateObject(options, 'options'); - - if (!ArrayIsArray(options.categories)) { - throw new ERR_INVALID_ARG_TYPE('options.categories', 'string[]', - options.categories); - } + validateStringArray(options.categories, 'options.categories'); if (options.categories.length <= 0) throw new ERR_TRACE_EVENTS_CATEGORY_REQUIRED();