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

Function formatNamespaceObject

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

Source from the content-addressed store, hash-verified

2267}
2268
2269function formatNamespaceObject(keys, ctx, value, recurseTimes) {
2270 const output = new Array(keys.length);
2271 for (let i = 0; i < keys.length; i++) {
2272 try {
2273 output[i] = formatProperty(ctx, value, recurseTimes, keys[i],
2274 kObjectType);
2275 } catch (err) {
2276 assert(isNativeError(err) && err.name === 'ReferenceError');
2277 // Use the existing functionality. This makes sure the indentation and
2278 // line breaks are always correct. Otherwise it is very difficult to keep
2279 // this aligned, even though this is a hacky way of dealing with this.
2280 const tmp = { [keys[i]]: '' };
2281 output[i] = formatProperty(ctx, tmp, recurseTimes, keys[i], kObjectType);
2282 const pos = StringPrototypeLastIndexOf(output[i], ' ');
2283 // We have to find the last whitespace and have to replace that value as
2284 // it will be visualized as a regular string.
2285 output[i] = StringPrototypeSlice(output[i], 0, pos + 1) +
2286 ctx.stylize('<uninitialized>', 'special');
2287 }
2288 }
2289 // Reset the keys to an empty array. This prevents duplicated inspection.
2290 keys.length = 0;
2291 return output;
2292}
2293
2294// The array is sparse and/or has extra keys
2295function formatSpecialArray(ctx, value, recurseTimes, maxLength, output, i) {

Callers

nothing calls this directly

Calls 2

formatPropertyFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…