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

Function createRepl

lib/internal/debugger/inspect_repl.js:365–1250  ·  view source on GitHub ↗
(inspector)

Source from the content-addressed store, hash-verified

363}
364
365function createRepl(inspector) {
366 const { Debugger, HeapProfiler, Profiler, Runtime } = inspector;
367
368 let repl;
369
370 // Things we want to keep around
371 const history = { control: [], debug: [] };
372 const watchedExpressions = [];
373 const knownBreakpoints = [];
374 let heapSnapshotPromise = null;
375 let pauseOnExceptionState = 'none';
376 let lastCommand;
377
378 // Things we need to reset when the app restarts
379 let knownScripts;
380 let currentBacktrace;
381 let selectedFrame;
382 let exitDebugRepl;
383 let contextLineNumber = 2;
384 let initialBreakRender;
385 let waitForInitialBreakRender = false;
386
387 function resetOnStart() {
388 knownScripts = {};
389 currentBacktrace = null;
390 selectedFrame = null;
391
392 if (exitDebugRepl) exitDebugRepl();
393 exitDebugRepl = null;
394 }
395 resetOnStart();
396
397 const INSPECT_OPTIONS = { colors: inspector.stdout.isTTY };
398 function inspect(value) {
399 return utilInspect(value, INSPECT_OPTIONS);
400 }
401
402 function print(value, addNewline = true) {
403 const text = typeof value === 'string' ? value : inspect(value);
404 return inspector.print(text, addNewline);
405 }
406
407 function getCurrentLocation() {
408 if (!selectedFrame) {
409 throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
410 }
411 return selectedFrame.location;
412 }
413
414 function isCurrentScript(script) {
415 return selectedFrame && getCurrentLocation().scriptId === script.scriptId;
416 }
417
418 function formatScripts(displayNatives = false) {
419 function isVisible(script) {
420 if (displayNatives) return true;
421 return !script.isNative || isCurrentScript(script);
422 }

Callers 1

constructorMethod · 0.70

Calls 15

resetOnStartFunction · 0.85
formatScriptsFunction · 0.85
formatWatchersFunction · 0.85
isNativeUrlFunction · 0.85
initAfterStartFunction · 0.85
initializeContextFunction · 0.85
callMethodMethod · 0.80
suspendReplWhileMethod · 0.80
createAndRegisterMethod · 0.80
defineCommandMethod · 0.80
getRelativePathFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…