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

Function formatWatchers

lib/internal/debugger/inspect_repl.js:659–680  ·  view source on GitHub ↗
(verbose = false)

Source from the content-addressed store, hash-verified

657 }
658
659 async function formatWatchers(verbose = false) {
660 if (!watchedExpressions.length) {
661 return '';
662 }
663
664 const inspectValue = (expr) =>
665 PromisePrototypeThen(evalInCurrentContext(expr), undefined,
666 (error) => `<${error.message}>`);
667 const lastIndex = watchedExpressions.length - 1;
668
669 const values = await SafePromiseAllReturnArrayLike(watchedExpressions, inspectValue);
670 const lines = ArrayPrototypeMap(watchedExpressions, (expr, idx) => {
671 const prefix = `${leftPad(idx, ' ', lastIndex)}: ${expr} =`;
672 const value = inspect(values[idx]);
673 if (!StringPrototypeIncludes(value, '\n')) {
674 return `${prefix} ${value}`;
675 }
676 return `${prefix}\n ${StringPrototypeReplaceAll(value, '\n', '\n ')}`;
677 });
678 const valueList = ArrayPrototypeJoin(lines, '\n');
679 return verbose ? `Watchers:\n${valueList}\n` : valueList;
680 }
681
682 function watchers(verbose = false) {
683 return PromisePrototypeThen(formatWatchers(verbose), print);

Callers 2

watchersFunction · 0.85
createReplFunction · 0.85

Calls 2

leftPadFunction · 0.85
inspectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…