@@ -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+ */
137166function 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+ */
146181function inspectorWaitForDebugger ( ) {
147182 if ( ! waitForDebugger ( ) )
148183 throw new ERR_INSPECTOR_NOT_ACTIVE ( ) ;
@@ -151,7 +186,7 @@ function inspectorWaitForDebugger() {
151186module . 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