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

Function getBoxedBase

lib/internal/util/inspect.js:1511–1549  ·  view source on GitHub ↗
(value, ctx, keys, constructor, tag)

Source from the content-addressed store, hash-verified

1509}
1510
1511function getBoxedBase(value, ctx, keys, constructor, tag) {
1512 let fn;
1513 let type;
1514 if (isNumberObject(value)) {
1515 fn = NumberPrototypeValueOf;
1516 type = 'Number';
1517 } else if (isStringObject(value)) {
1518 fn = StringPrototypeValueOf;
1519 type = 'String';
1520 // For boxed Strings, we have to remove the 0-n indexed entries,
1521 // since they just noisy up the output and are redundant
1522 // Make boxed primitive Strings look like such
1523 keys.splice(0, value.length);
1524 } else if (isBooleanObject(value)) {
1525 fn = BooleanPrototypeValueOf;
1526 type = 'Boolean';
1527 } else if (isBigIntObject(value)) {
1528 fn = BigIntPrototypeValueOf;
1529 type = 'BigInt';
1530 } else {
1531 fn = SymbolPrototypeValueOf;
1532 type = 'Symbol';
1533 }
1534 let base = `[${type}`;
1535 if (type !== constructor) {
1536 if (constructor === null) {
1537 base += ' (null prototype)';
1538 } else {
1539 base += ` (${constructor})`;
1540 }
1541 }
1542 base += `: ${formatPrimitive(stylizeNoColor, fn(value), ctx)}]`;
1543 if (tag !== '' && tag !== constructor) {
1544 base += ` [${tag}]`;
1545 }
1546 if (keys.length !== 0 || ctx.stylize === stylizeNoColor)
1547 return base;
1548 return ctx.stylize(base, StringPrototypeToLowerCase(type));
1549}
1550
1551function getClassBase(value, constructor, tag) {
1552 const hasName = ObjectPrototypeHasOwnProperty(value, 'name');

Callers 1

formatRawFunction · 0.85

Calls 2

formatPrimitiveFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…