Skip to content

Commit

Permalink
trace_events: refactor to use validateStringArray
Browse files Browse the repository at this point in the history
  • Loading branch information
deokjinkim committed Dec 29, 2022
1 parent 4830a6c commit 98d5622
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/trace_events.js
Expand Up @@ -17,7 +17,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 +28,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 +84,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 98d5622

Please sign in to comment.