Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace_events: refactor to use validateStringArray #46012

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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