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

Function prepareControlCode

lib/internal/debugger/inspect_repl.js:576–593  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

574 }
575
576 function prepareControlCode(input) {
577 if (input === '\n') return lastCommand;
578 // Add parentheses: exec process.title => exec("process.title");
579 const match = RegExpPrototypeExec(/^\s*(?:exec|p)\s+([^\n]*)/, input);
580 input = match ? match[1] : input;
581
582 if (isObjectLiteral(input)) {
583 // Add parentheses to make sure `input` is parsed as an expression
584 input = `(${StringPrototypeTrim(input)})\n`;
585 }
586
587 if (match) {
588 lastCommand = `exec(${JSONStringify(input)})`;
589 } else {
590 lastCommand = input;
591 }
592 return lastCommand;
593 }
594
595 async function evalInCurrentContext(code) {
596 // Repl asked for scope variables

Callers 1

controlEvalFunction · 0.85

Calls 1

isObjectLiteralFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…