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

Method constructor

lib/internal/debugger/inspect.js:72–124  ·  view source on GitHub ↗
(options, stdin, stdout)

Source from the content-addressed store, hash-verified

70
71class NodeInspector {
72 constructor(options, stdin, stdout) {
73 this.options = options;
74 this.stdin = stdin;
75 this.stdout = stdout;
76
77 this.paused = true;
78 this.child = null;
79
80 if (options.script) {
81 this._runScript = FunctionPrototypeBind(
82 launchChildProcess, null,
83 [options.script, ...options.scriptArgs],
84 options.host,
85 options.port,
86 FunctionPrototypeBind(this.childPrint, this));
87 } else {
88 this._runScript =
89 () => PromiseResolve([null, options.port, options.host]);
90 }
91
92 this.client = new InspectClient();
93
94 this.domainNames = ['Debugger', 'HeapProfiler', 'Profiler', 'Runtime'];
95 ArrayPrototypeForEach(this.domainNames, (domain) => {
96 this[domain] = createAgentProxy(domain, this.client);
97 });
98 this.handleDebugEvent = (fullName, params) => {
99 const { 0: domain, 1: name } = StringPrototypeSplit(fullName, '.', 2);
100 if (domain in this) {
101 this[domain].emit(name, params);
102 }
103 };
104 this.client.on('debugEvent', this.handleDebugEvent);
105 const startRepl = createRepl(this);
106
107 // Handle all possible exits
108 process.on('exit', () => this.killChild());
109 const exitCodeZero = () => process.exit(kNoFailure);
110 process.once('SIGTERM', exitCodeZero);
111 process.once('SIGHUP', exitCodeZero);
112
113 (async () => {
114 try {
115 await this.run();
116 const repl = await startRepl();
117 this.repl = repl;
118 this.repl.on('exit', exitCodeZero);
119 this.paused = false;
120 } catch (error) {
121 process.nextTick(() => { throw error; });
122 }
123 })();
124 }
125
126 suspendReplWhile(fn) {
127 if (this.repl) {

Callers

nothing calls this directly

Calls 7

killChildMethod · 0.95
runMethod · 0.95
createAgentProxyFunction · 0.85
createReplFunction · 0.70
emitMethod · 0.45
onMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected