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

Function getFunctionBase

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

Source from the content-addressed store, hash-verified

1570}
1571
1572function getFunctionBase(ctx, value, constructor, tag) {
1573 const stringified = FunctionPrototypeToString(value);
1574 if (StringPrototypeStartsWith(stringified, 'class') && stringified[stringified.length - 1] === '}') {
1575 const slice = StringPrototypeSlice(stringified, 5, -1);
1576 const bracketIndex = StringPrototypeIndexOf(slice, '{');
1577 if (bracketIndex !== -1 &&
1578 (!StringPrototypeIncludes(StringPrototypeSlice(slice, 0, bracketIndex), '(') ||
1579 // Slow path to guarantee that it's indeed a class.
1580 RegExpPrototypeExec(classRegExp, RegExpPrototypeSymbolReplace(stripCommentsRegExp, slice)) !== null)
1581 ) {
1582 return getClassBase(value, constructor, tag);
1583 }
1584 }
1585 let type = 'Function';
1586 if (isGeneratorFunction(value)) {
1587 type = `Generator${type}`;
1588 }
1589 if (isAsyncFunction(value)) {
1590 type = `Async${type}`;
1591 }
1592 let base = `[${type}`;
1593 if (constructor === null) {
1594 base += ' (null prototype)';
1595 }
1596 if (value.name === '') {
1597 base += ' (anonymous)';
1598 } else {
1599 base += `: ${typeof value.name === 'string' ? value.name : formatValue(ctx, value.name)}`;
1600 }
1601 base += ']';
1602 if (constructor !== type && constructor !== null) {
1603 base += ` ${constructor}`;
1604 }
1605 if (tag !== '' && constructor !== tag) {
1606 base += ` [${tag}]`;
1607 }
1608 return base;
1609}
1610
1611function identicalSequenceRange(a, b) {
1612 for (let i = 0; i < a.length - 3; i++) {

Callers 1

formatRawFunction · 0.85

Calls 3

getClassBaseFunction · 0.85
isAsyncFunctionFunction · 0.85
formatValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…