Skip to content

Commit

Permalink
fixup! fixup! repl: refactor to avoid unsafe array iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
RaisinTen committed Jan 14, 2021
1 parent 878dbe2 commit 4fab6a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const {
RegExp,
RegExpPrototypeTest,
RegExpPrototypeToString,
SafeArrayIterator,
SafeStringIterator,
SafeMap,
SafeSet,
Expand Down Expand Up @@ -1870,18 +1871,19 @@ function tryStringify(arg) {
}

function format(...args) {
return formatWithOptionsInternal(undefined, args);
return formatWithOptionsInternal(undefined, ...new SafeArrayIterator(args));
}

function formatWithOptions(inspectOptions, ...args) {
if (typeof inspectOptions !== 'object' || inspectOptions === null) {
throw new ERR_INVALID_ARG_TYPE(
'inspectOptions', 'object', inspectOptions);
}
return formatWithOptionsInternal(inspectOptions, args);
return formatWithOptionsInternal(inspectOptions,
...new SafeArrayIterator(args));
}

function formatWithOptionsInternal(inspectOptions, args) {
function formatWithOptionsInternal(inspectOptions, ...args) {
const first = args[0];
let a = 0;
let str = '';
Expand Down

0 comments on commit 4fab6a8

Please sign in to comment.