Memit
Bun

method

inspector.Session.emit

event: string | symbol,
...args: any[]
): boolean;

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

Returns true if the event had listeners, false otherwise.

import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();

// First listener
myEmitter.on('event', function firstListener() {
  console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
  console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
  const parameters = args.join(', ');
  console.log(`event with parameters ${parameters} in third listener`);
});

console.log(myEmitter.listeners('event'));

myEmitter.emit('event', 1, 2, 3, 4, 5);

// Prints:
// [
//   [Function: firstListener],
//   [Function: secondListener],
//   [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
event: 'inspectorNotification',
message: InspectorNotification<object>
): boolean;
event: 'Runtime.executionContextCreated',
): boolean;
event: 'Runtime.executionContextDestroyed',
): boolean;
event: 'Runtime.executionContextsCleared'
): boolean;
event: 'Runtime.exceptionThrown',
): boolean;
event: 'Runtime.exceptionRevoked',
): boolean;
event: 'Runtime.consoleAPICalled',
): boolean;
event: 'Runtime.inspectRequested',
): boolean;
event: 'Debugger.scriptParsed',
): boolean;
event: 'Debugger.scriptFailedToParse',
): boolean;
event: 'Debugger.breakpointResolved',
): boolean;
event: 'Debugger.paused',
): boolean;
event: 'Debugger.resumed'
): boolean;
event: 'Console.messageAdded',
): boolean;
event: 'Profiler.consoleProfileStarted',
): boolean;
event: 'Profiler.consoleProfileFinished',
): boolean;
event: 'HeapProfiler.addHeapSnapshotChunk',
): boolean;
event: 'HeapProfiler.resetProfiles'
): boolean;
event: 'HeapProfiler.reportHeapSnapshotProgress',
): boolean;
event: 'HeapProfiler.lastSeenObjectId',
): boolean;
event: 'HeapProfiler.heapStatsUpdate',
): boolean;
event: 'NodeTracing.dataCollected',
): boolean;
event: 'NodeTracing.tracingComplete'
): boolean;
event: 'NodeWorker.attachedToWorker',
): boolean;
event: 'NodeWorker.detachedFromWorker',
): boolean;
event: 'NodeWorker.receivedMessageFromWorker',
): boolean;
event: 'Network.requestWillBeSent',
): boolean;
event: 'Network.responseReceived',
): boolean;
event: 'Network.loadingFailed',
): boolean;
event: 'Network.loadingFinished',
): boolean;
event: 'Network.dataReceived',
): boolean;
event: 'Network.webSocketCreated',
): boolean;
event: 'Network.webSocketClosed',
): boolean;
event: 'Network.webSocketHandshakeResponseReceived',
): boolean;
event: 'NodeRuntime.waitingForDisconnect'
): boolean;
event: 'NodeRuntime.waitingForDebugger'
): boolean;
event: 'Target.targetCreated',
): boolean;
event: 'Target.attachedToTarget',
): boolean;

Referenced types

interface InspectorNotification<T>

interface ExecutionContextDestroyedEventDataType

interface ExceptionThrownEventDataType

interface ExceptionRevokedEventDataType

  • exceptionId: number

    The id of revoked exception, as reported in <code>exceptionThrown</code>.

  • reason: string

    Reason describing why exception was revoked.

interface ConsoleAPICalledEventDataType

  • args: RemoteObject[]

    Call arguments.

  • context?: string

    Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context.

  • executionContextId: number

    Identifier of the context where the call was made.

  • stackTrace?: StackTrace

    Stack trace captured when the call was made.

  • timestamp: number

    Call timestamp.

  • type: string

    Type of the call.

interface ScriptParsedEventDataType

  • endColumn: number

    Length of the last line of the script.

  • endLine: number

    Last line of the script.

  • executionContextAuxData?: object

    Embedder-specific auxiliary data.

  • executionContextId: number

    Specifies script creation context.

  • hash: string

    Content hash of the script.

  • hasSourceURL?: boolean

    True, if this script has sourceURL.

  • isLiveEdit?: boolean

    True, if this script is generated as a result of the live edit operation.

  • isModule?: boolean

    True, if this script is ES6 module.

  • length?: number

    This script length.

  • scriptId: string

    Identifier of the script parsed.

  • sourceMapURL?: string

    URL of source map associated with script (if any).

  • stackTrace?: StackTrace

    JavaScript top stack frame of where the script parsed event was triggered if available.

  • startColumn: number

    Column offset of the script within the resource with given URL.

  • startLine: number

    Line offset of the script within the resource with given URL (for script tags).

  • url: string

    URL or name of the script parsed (if any).

interface ScriptFailedToParseEventDataType

  • endColumn: number

    Length of the last line of the script.

  • endLine: number

    Last line of the script.

  • executionContextAuxData?: object

    Embedder-specific auxiliary data.

  • executionContextId: number

    Specifies script creation context.

  • hash: string

    Content hash of the script.

  • hasSourceURL?: boolean

    True, if this script has sourceURL.

  • isModule?: boolean

    True, if this script is ES6 module.

  • length?: number

    This script length.

  • scriptId: string

    Identifier of the script parsed.

  • sourceMapURL?: string

    URL of source map associated with script (if any).

  • stackTrace?: StackTrace

    JavaScript top stack frame of where the script parsed event was triggered if available.

  • startColumn: number

    Column offset of the script within the resource with given URL.

  • startLine: number

    Line offset of the script within the resource with given URL (for script tags).

  • url: string

    URL or name of the script parsed (if any).

interface BreakpointResolvedEventDataType

interface PausedEventDataType

interface MessageAddedEventDataType

interface ConsoleProfileStartedEventDataType

  • id: string
  • location: Location

    Location of console.profile().

  • title?: string

    Profile title passed as an argument to console.profile().

interface ConsoleProfileFinishedEventDataType

interface HeapStatsUpdateEventDataType

  • statsUpdate: number[]

    An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment.

interface AttachedToWorkerEventDataType

interface DetachedFromWorkerEventDataType

  • sessionId: string

    Detached session identifier.

interface ReceivedMessageFromWorkerEventDataType

interface RequestWillBeSentEventDataType

interface ResponseReceivedEventDataType

interface LoadingFailedEventDataType

interface LoadingFinishedEventDataType

interface DataReceivedEventDataType

interface WebSocketCreatedEventDataType

interface WebSocketClosedEventDataType

interface WebSocketHandshakeResponseReceivedEventDataType