MCPcopy Index your code
hub / github.com/nodejs/node / formatSpecialArray

Function formatSpecialArray

lib/internal/util/inspect.js:2295–2332  ·  view source on GitHub ↗
(ctx, value, recurseTimes, maxLength, output, i)

Source from the content-addressed store, hash-verified

2293
2294// The array is sparse and/or has extra keys
2295function formatSpecialArray(ctx, value, recurseTimes, maxLength, output, i) {
2296 const keys = ObjectKeys(value);
2297 let index = i;
2298 for (; i < keys.length && output.length < maxLength; i++) {
2299 const key = keys[i];
2300 const tmp = +key;
2301 // Arrays can only have up to 2^32 - 1 entries
2302 if (tmp > 2 ** 32 - 2) {
2303 break;
2304 }
2305 if (`${index}` !== key) {
2306 if (RegExpPrototypeExec(numberRegExp, key) === null) {
2307 break;
2308 }
2309 const emptyItems = tmp - index;
2310 const ending = emptyItems > 1 ? 's' : '';
2311 const message = `<${emptyItems} empty item${ending}>`;
2312 ArrayPrototypePush(output, ctx.stylize(message, 'undefined'));
2313 index = tmp;
2314 if (output.length === maxLength) {
2315 break;
2316 }
2317 }
2318 ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, key, kArrayType));
2319 index++;
2320 }
2321 const remaining = value.length - index;
2322 if (output.length !== maxLength) {
2323 if (remaining > 0) {
2324 const ending = remaining > 1 ? 's' : '';
2325 const message = `<${remaining} empty item${ending}>`;
2326 ArrayPrototypePush(output, ctx.stylize(message, 'undefined'));
2327 }
2328 } else if (remaining > 0) {
2329 ArrayPrototypePush(output, remainingText(remaining));
2330 }
2331 return output;
2332}
2333
2334function formatArrayBuffer(ctx, value) {
2335 let buffer;

Callers 1

formatArrayFunction · 0.85

Calls 2

formatPropertyFunction · 0.85
remainingTextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…