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

Function evalInCurrentContext

lib/internal/debugger/inspect_repl.js:595–618  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

593 }
594
595 async function evalInCurrentContext(code) {
596 // Repl asked for scope variables
597 if (code === '.scope') {
598 if (!selectedFrame) {
599 throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
600 }
601 const scopes = await selectedFrame.loadScopes();
602 return ArrayPrototypeMap(scopes, (scope) => scope.completionGroup);
603 }
604
605 if (selectedFrame) {
606 return PromisePrototypeThen(Debugger.evaluateOnCallFrame({
607 callFrameId: selectedFrame.callFrameId,
608 expression: code,
609 objectGroup: 'node-inspect',
610 generatePreview: true,
611 }), RemoteObject.fromEvalResult);
612 }
613 return PromisePrototypeThen(Runtime.evaluate({
614 expression: code,
615 objectGroup: 'node-inspect',
616 generatePreview: true,
617 }), RemoteObject.fromEvalResult);
618 }
619
620 function controlEval(input, context, filename, callback) {
621 debuglog('eval:', input);

Callers 3

debugEvalFunction · 0.85
inspectValueFunction · 0.85
execFunction · 0.85

Calls 3

loadScopesMethod · 0.80
evaluateOnCallFrameMethod · 0.80
evaluateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…