Skip to content

Commit 4fab6a8

Browse files
committed
fixup! fixup! repl: refactor to avoid unsafe array iteration
1 parent 878dbe2 commit 4fab6a8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/internal/util/inspect.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const {
4646
RegExp,
4747
RegExpPrototypeTest,
4848
RegExpPrototypeToString,
49+
SafeArrayIterator,
4950
SafeStringIterator,
5051
SafeMap,
5152
SafeSet,
@@ -1870,18 +1871,19 @@ function tryStringify(arg) {
18701871
}
18711872

18721873
function format(...args) {
1873-
return formatWithOptionsInternal(undefined, args);
1874+
return formatWithOptionsInternal(undefined, ...new SafeArrayIterator(args));
18741875
}
18751876

18761877
function formatWithOptions(inspectOptions, ...args) {
18771878
if (typeof inspectOptions !== 'object' || inspectOptions === null) {
18781879
throw new ERR_INVALID_ARG_TYPE(
18791880
'inspectOptions', 'object', inspectOptions);
18801881
}
1881-
return formatWithOptionsInternal(inspectOptions, args);
1882+
return formatWithOptionsInternal(inspectOptions,
1883+
...new SafeArrayIterator(args));
18821884
}
18831885

1884-
function formatWithOptionsInternal(inspectOptions, args) {
1886+
function formatWithOptionsInternal(inspectOptions, ...args) {
18851887
const first = args[0];
18861888
let a = 0;
18871889
let str = '';

0 commit comments

Comments
 (0)