Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da859b5

Browse filesBrowse files
VoltrexKeyvatargos
authored andcommitted
typings: add JSDoc typings for inspector
Added JSDoc typings for the `inspector` lib module. PR-URL: #38390 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Adrian Estrada <edsadr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent c700de3 commit da859b5
Copy full SHA for da859b5

File tree

Expand file treeCollapse file tree

1 file changed

+36
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+36
-1
lines changed
Open diff view settings
Collapse file

‎lib/inspector.js‎

Copy file name to clipboardExpand all lines: lib/inspector.js
+36-1Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,22 @@ class Session extends EventEmitter {
5353
this[messageCallbacksSymbol] = new SafeMap();
5454
}
5555

56+
/**
57+
* Connects the session to the inspector back-end.
58+
* @returns {void}
59+
*/
5660
connect() {
5761
if (this[connectionSymbol])
5862
throw new ERR_INSPECTOR_ALREADY_CONNECTED('The inspector session');
5963
this[connectionSymbol] =
6064
new Connection((message) => this[onMessageSymbol](message));
6165
}
6266

67+
/**
68+
* Connects the session to the main thread
69+
* inspector back-end.
70+
* @returns {void}
71+
*/
6372
connectToMainThread() {
6473
if (isMainThread)
6574
throw new ERR_INSPECTOR_NOT_WORKER();
@@ -93,6 +102,13 @@ class Session extends EventEmitter {
93102
}
94103
}
95104

105+
/**
106+
* Posts a message to the inspector back-end.
107+
* @param {string} method
108+
* @param {Record<unknown, unknown>} [params]
109+
* @param {Function} [callback]
110+
* @returns {void}
111+
*/
96112
post(method, params, callback) {
97113
validateString(method, 'method');
98114
if (!callback && typeof params === 'function') {
@@ -120,6 +136,12 @@ class Session extends EventEmitter {
120136
this[connectionSymbol].dispatch(JSONStringify(message));
121137
}
122138

139+
/**
140+
* Immediately closes the session, all pending
141+
* message callbacks will be called with an
142+
* error.
143+
* @returns {void}
144+
*/
123145
disconnect() {
124146
if (!this[connectionSymbol])
125147
return;
@@ -134,6 +156,13 @@ class Session extends EventEmitter {
134156
}
135157
}
136158

159+
/**
160+
* Activates inspector on host and port.
161+
* @param {number} [port]
162+
* @param {string} [host]
163+
* @param {boolean} [wait]
164+
* @returns {void}
165+
*/
137166
function inspectorOpen(port, host, wait) {
138167
if (isEnabled()) {
139168
throw new ERR_INSPECTOR_ALREADY_ACTIVATED();
@@ -143,6 +172,12 @@ function inspectorOpen(port, host, wait) {
143172
waitForDebugger();
144173
}
145174

175+
/**
176+
* Blocks until a client (existing or connected later)
177+
* has sent the `Runtime.runIfWaitingForDebugger`
178+
* command.
179+
* @returns {void}
180+
*/
146181
function inspectorWaitForDebugger() {
147182
if (!waitForDebugger())
148183
throw new ERR_INSPECTOR_NOT_ACTIVE();
@@ -151,7 +186,7 @@ function inspectorWaitForDebugger() {
151186
module.exports = {
152187
open: inspectorOpen,
153188
close: process._debugEnd,
154-
url: url,
189+
url,
155190
waitForDebugger: inspectorWaitForDebugger,
156191
// This is dynamically added during bootstrap,
157192
// where the console from the VM is still available

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.