diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 2672ccb50bfa1c..b03380030a6be5 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -4,6 +4,7 @@ const { Array, ArrayIsArray, ArrayPrototypeFilter, + ArrayPrototypeForEach, ArrayPrototypePush, ArrayPrototypeSort, ArrayPrototypeUnshift, @@ -462,12 +463,13 @@ function strEscape(str) { // instead wrap the text in double quotes. If double quotes exist, check for // backticks. If they do not exist, use those as fallback instead of the // double quotes. - if (str.includes("'")) { + if (StringPrototypeIncludes(str, "'")) { // This invalidates the charCode and therefore can not be matched for // anymore. - if (!str.includes('"')) { + if (!StringPrototypeIncludes(str, '"')) { singleQuote = -1; - } else if (!str.includes('`') && !str.includes('${')) { + } else if (!StringPrototypeIncludes(str, '`') && + !StringPrototypeIncludes(str, '${')) { singleQuote = -2; } if (singleQuote !== 39) { @@ -488,7 +490,7 @@ function strEscape(str) { let last = 0; const lastIndex = str.length; for (let i = 0; i < lastIndex; i++) { - const point = str.charCodeAt(i); + const point = StringPrototypeCharCodeAt(str, i); if (point === singleQuote || point === 92 || point < 32 || @@ -609,13 +611,13 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) { if (depth === 0) { keySet = new SafeSet(); } else { - keys.forEach((key) => keySet.add(key)); + ArrayPrototypeForEach(keys, (key) => keySet.add(key)); } // Get all own property names and symbols. keys = ObjectGetOwnPropertyNames(obj); const symbols = ObjectGetOwnPropertySymbols(obj); if (symbols.length !== 0) { - keys.push(...symbols); + ArrayPrototypePush(keys, ...symbols); } for (const key of keys) { // Ignore the `constructor` property and keys that exist on layers above. @@ -632,9 +634,9 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) { ctx, obj, recurseTimes, key, kObjectType, desc, main); if (ctx.colors) { // Faint! - output.push(`\u001b[2m${value}\u001b[22m`); + ArrayPrototypePush(output, `\u001b[2m${value}\u001b[22m`); } else { - output.push(value); + ArrayPrototypePush(output, value); } } // Limit the inspection to up to three prototype layers. Using `recurseTimes`