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

Function formatArray

lib/internal/util/inspect.js:2358–2376  ·  view source on GitHub ↗
(ctx, value, recurseTimes)

Source from the content-addressed store, hash-verified

2356}
2357
2358function formatArray(ctx, value, recurseTimes) {
2359 const valLen = value.length;
2360 const len = MathMin(MathMax(0, ctx.maxArrayLength), valLen);
2361
2362 const remaining = valLen - len;
2363 const output = [];
2364 for (let i = 0; i < len; i++) {
2365 const desc = ObjectGetOwnPropertyDescriptor(value, i);
2366 if (desc === undefined) {
2367 // Special handle sparse arrays.
2368 return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
2369 }
2370 ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType, desc));
2371 }
2372 if (remaining > 0) {
2373 ArrayPrototypePush(output, remainingText(remaining));
2374 }
2375 return output;
2376}
2377
2378function formatTypedArray(value, length, ctx) {
2379 const maxLength = MathMin(MathMax(0, ctx.maxArrayLength), length);

Callers

nothing calls this directly

Calls 3

formatSpecialArrayFunction · 0.85
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…