MCPcopy Create free account
hub / github.com/nodejs/node / [customInspectSymbol]

Method [customInspectSymbol]

lib/internal/debugger/inspect_repl.js:474–508  ·  view source on GitHub ↗
(depth, options)

Source from the content-addressed store, hash-verified

472 }
473
474 [customInspectSymbol](depth, options) {
475 const { scriptId, lineNumber, columnNumber, delta, scriptSource } = this;
476 const start = MathMax(1, lineNumber - delta + 1);
477 const end = lineNumber + delta + 1;
478
479 const lines = StringPrototypeSplit(scriptSource, '\n');
480 return ArrayPrototypeJoin(
481 ArrayPrototypeMap(
482 ArrayPrototypeSlice(lines, start - 1, end),
483 (lineText, offset) => {
484 const i = start + offset;
485 const isCurrent = i === (lineNumber + 1);
486
487 const markedLine = isCurrent ?
488 markSourceColumn(lineText, columnNumber, options.colors) :
489 lineText;
490
491 let isBreakpoint = false;
492 ArrayPrototypeForEach(knownBreakpoints, ({ location }) => {
493 if (!location) return;
494 if (scriptId === location.scriptId &&
495 i === (location.lineNumber + 1)) {
496 isBreakpoint = true;
497 }
498 });
499
500 let prefixChar = ' ';
501 if (isCurrent) {
502 prefixChar = '>';
503 } else if (isBreakpoint) {
504 prefixChar = '*';
505 }
506 return `${leftPad(i, prefixChar, end)} ${markedLine}`;
507 }), '\n');
508 }
509 }
510
511 async function getSourceSnippet(location, delta = 5) {

Callers

nothing calls this directly

Calls 2

markSourceColumnFunction · 0.85
leftPadFunction · 0.85

Tested by

no test coverage detected