Skip to content

Commit

Permalink
trace_events: refactor to use validateStringArray
Browse files Browse the repository at this point in the history
`options.categories` is string[]. So used `validateStringArray`

Refs: https://nodejs.org/dist/latest-v19.x/docs/api/tracing.html#trace_eventscreatetracingoptions
PR-URL: #46012
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
deokjinkim authored Jan 19, 2023
1 parent 94199c8 commit 8a74477
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/trace_events.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const {
ArrayIsArray,
ArrayPrototypeJoin,
SafeSet,
Symbol,
Expand All @@ -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');
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8a74477

Please sign in to comment.