Skip to content

WebSocketShardConnector

A WebSocket Shard Connector for connecting to Twitch WebSocket EventSub service.

Extends

  • client

Constructors

new WebSocketShardConnector()

1
new WebSocketShardConnector(connection: WebSocketShard): WebSocketShardConnector

Builds up a WebSocketShardConnector.

Parameters

ParameterTypeDescription
connectionWebSocketShardThe WebSocket Shard to connect to.

Returns

WebSocketShardConnector

Overrides

client.constructor

Source

twitchfy/packages/eventsub/src/structures/WebSocketShardConnector.ts:41

Properties

PropertyModifierTypeDescriptionInherited from
connectionreadonlyWebSocketShardThe WebSocket Shard to connect to.-
connectionURLpublicstringThe connection URL of the WebSocket server used.-
sessionIdreadonlystringThe session id of the shard.-
wsConnectionpublicconnectionThe WebSocket connection used.-
captureRejectionSymbolreadonlytypeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

See how to write a custom rejection handler.

Since

v13.4.0, v12.16.0

client.captureRejectionSymbol
captureRejectionsstaticboolean

Value: boolean

Change the default captureRejections option on all new EventEmitter objects.

Since

v13.4.0, v12.16.0

client.captureRejections
defaultMaxListenersstaticnumber

By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual EventEmitter instances using the emitter.setMaxListeners(n) method. To change the default for allEventEmitter instances, the events.defaultMaxListenersproperty can be used. If this value is not a positive number, a RangeErroris thrown.

Take caution when setting the events.defaultMaxListeners because the change affects allEventEmitter instances, including those created before the change is made. However, calling emitter.setMaxListeners(n) still has precedence over events.defaultMaxListeners.

This is not a hard limit. The EventEmitter instance will allow more listeners to be added but will output a trace warning to stderr indicating that a “possible EventEmitter memory leak” has been detected. For any singleEventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners()methods can be used to temporarily avoid this warning:

import { EventEmitter } from ‘node:events ’;

const emitter = new EventEmitter();

emitter.setMaxListeners(emitter.getMaxListeners() + 1);

emitter.once(‘event’, () => {

// do stuff

emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));

});

The --trace-warnings command-line flag can be used to display the stack trace for such warnings.

The emitted warning can be inspected with process.on('warning') and will have the additional emitter, type, and count properties, referring to the event emitter instance, the event’s name and the number of attached listeners, respectively. Its name property is set to 'MaxListenersExceededWarning'.

Since

v0.11.2

client.defaultMaxListeners
errorMonitorreadonlytypeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error'events. Listeners installed using this symbol are called before the regular'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an'error' event is emitted. Therefore, the process will still crash if no regular 'error' listener is installed.

Since

v13.6.0, v12.17.0

client.errorMonitor

Methods

[captureRejectionSymbol]()?

1
optional [captureRejectionSymbol](
2
error: Error,
3
event: string, ...
4
args: any[]): void

Parameters

ParameterType
errorError
eventstring
argsany[]

Returns

void

Inherited from

client.[captureRejectionSymbol]

Source

twitchfy/node_modules/@types/node/events.d.ts:112


abort()

1
abort(): void

Will cancel an in-progress connection request before either the connect event or the connectFailed event has been emitted. If the connect or connectFailed event has already been emitted, calling abort() will do nothing.

Returns

void

Inherited from

client.abort

Source

twitchfy/node_modules/@types/websocket/index.d.ts:642


addListener()

addListener(event, cb)

1
addListener(event: "connect", cb: (connection: connection) => void): this
Parameters
ParameterType
event"connect"
cb(connection: connection) => void
Returns

this

Inherited from

client.addListener

Source

twitchfy/node_modules/@types/websocket/index.d.ts:648

addListener(event, cb)

1
addListener(event: "connectFailed", cb: (err: Error) => void): this
Parameters
ParameterType
event"connectFailed"
cb(err: Error) => void
Returns

this

Inherited from

client.addListener

Source

twitchfy/node_modules/@types/websocket/index.d.ts:649

addListener(event, cb)

1
addListener(event: "httpResponse", cb: (response: IncomingMessage, client: client) => void): this
Parameters
ParameterType
event"httpResponse"
cb(response: IncomingMessage, client: client) => void
Returns

this

Inherited from

client.addListener

Source

twitchfy/node_modules/@types/websocket/index.d.ts:650


connect()

1
connect(url?: string): Promise<void>

Connects to the WebSocket server.

Parameters

ParameterTypeDescription
url?stringThe URL to connect to. If not specified it will use the default Twitch connection.

Returns

Promise<void>

Overrides

client.connect

Source

twitchfy/packages/eventsub/src/structures/WebSocketShardConnector.ts:58


emit()

1
emit(eventName: string | symbol, ...args: any[]): boolean

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

Returns true if the event had listeners, false otherwise.

1
import { EventEmitter } from 'node:events';
2
const myEmitter = new EventEmitter();
3
4
// First listener
5
myEmitter.on('event', function firstListener() {
6
console.log('Helloooo! first listener');
7
});
8
// Second listener
9
myEmitter.on('event', function secondListener(arg1, arg2) {
10
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
11
});
12
// Third listener
13
myEmitter.on('event', function thirdListener(...args) {
14
const parameters = args.join(', ');
15
console.log(`event with parameters ${parameters} in third listener`);
16
});
17
18
console.log(myEmitter.listeners('event'));
19
20
myEmitter.emit('event', 1, 2, 3, 4, 5);
21
22
// Prints:
23
// [
24
// [Function: firstListener],
25
// [Function: secondListener],
26
// [Function: thirdListener]
27
// ]
28
// Helloooo! first listener
29
// event with parameters 1, 2 in second listener
30
// event with parameters 1, 2, 3, 4, 5 in third listener

Parameters

ParameterType
eventNamestring | symbol
argsany[]

Returns

boolean

Inherited from

client.emit

Since

v0.1.26

Source

twitchfy/node_modules/@types/node/events.d.ts:807


eventNames()

1
eventNames(): (string | symbol)[]

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

1
import { EventEmitter } from 'node:events';
2
3
const myEE = new EventEmitter();
4
myEE.on('foo', () => {});
5
myEE.on('bar', () => {});
6
7
const sym = Symbol('symbol');
8
myEE.on(sym, () => {});
9
10
console.log(myEE.eventNames());
11
// Prints: [ 'foo', 'bar', Symbol(symbol) ]

Returns

(string | symbol)[]

Inherited from

client.eventNames

Since

v6.0.0

Source

twitchfy/node_modules/@types/node/events.d.ts:870


getMaxListeners()

1
getMaxListeners(): number

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

Returns

number

Inherited from

client.getMaxListeners

Since

v1.0.0

Source

twitchfy/node_modules/@types/node/events.d.ts:722


listenerCount()

1
listenerCount(eventName: string | symbol, listener?: Function): number

Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

Parameters

ParameterTypeDescription
eventNamestring | symbolThe name of the event being listened for
listener?FunctionThe event handler function

Returns

number

Inherited from

client.listenerCount

Since

v3.2.0

Source

twitchfy/node_modules/@types/node/events.d.ts:816


listeners()

1
listeners(eventName: string | symbol): Function[]

Returns a copy of the array of listeners for the event named eventName.

1
server.on('connection', (stream) => {
2
console.log('someone connected!');
3
});
4
console.log(util.inspect(server.listeners('connection')));
5
// Prints: [ [Function] ]

Parameters

ParameterType
eventNamestring | symbol

Returns

Function[]

Inherited from

client.listeners

Since

v0.1.26

Source

twitchfy/node_modules/@types/node/events.d.ts:735


off()

1
off(eventName: string | symbol, listener: (...args: any[]) => void): this

Alias for emitter.removeListener().

Parameters

ParameterType
eventNamestring | symbol
listener(…args: any[]) => void

Returns

this

Inherited from

client.off

Since

v10.0.0

Source

twitchfy/node_modules/@types/node/events.d.ts:695


on()

on(event, cb)

1
on(event: "connect", cb: (connection: connection) => void): this
Parameters
ParameterType
event"connect"
cb(connection: connection) => void
Returns

this

Inherited from

client.on

Source

twitchfy/node_modules/@types/websocket/index.d.ts:645

on(event, cb)

1
on(event: "connectFailed", cb: (err: Error) => void): this
Parameters
ParameterType
event"connectFailed"
cb(err: Error) => void
Returns

this

Inherited from

client.on

Source

twitchfy/node_modules/@types/websocket/index.d.ts:646

on(event, cb)

1
on(event: "httpResponse", cb: (response: IncomingMessage, client: client) => void): this
Parameters
ParameterType
event"httpResponse"
cb(response: IncomingMessage, client: client) => void
Returns

this

Inherited from

client.on

Source

twitchfy/node_modules/@types/websocket/index.d.ts:647


once()

1
once(eventName: string | symbol, listener: (...args: any[]) => void): this

Adds a one-timelistener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

1
server.once('connection', (stream) => {
2
console.log('Ah, we have our first user!');
3
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. Theemitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

1
import { EventEmitter } from 'node:events';
2
const myEE = new EventEmitter();
3
myEE.once('foo', () => console.log('a'));
4
myEE.prependOnceListener('foo', () => console.log('b'));
5
myEE.emit('foo');
6
// Prints:
7
// b
8
// a

Parameters

ParameterTypeDescription
eventNamestring | symbolThe name of the event.
listener(…args: any[]) => voidThe callback function

Returns

this

Inherited from

client.once

Since

v0.3.0

Source

twitchfy/node_modules/@types/node/events.d.ts:607


prependListener()

1
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventNameand listener will result in the listener being added, and called, multiple times.

1
server.prependListener('connection', (stream) => {
2
console.log('someone connected!');
3
});

Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

ParameterTypeDescription
eventNamestring | symbolThe name of the event.
listener(…args: any[]) => voidThe callback function

Returns

this

Inherited from

client.prependListener

Since

v6.0.0

Source

twitchfy/node_modules/@types/node/events.d.ts:834


prependOnceListener()

1
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this

Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

1
server.prependOnceListener('connection', (stream) => {
2
console.log('Ah, we have our first user!');
3
});

Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

ParameterTypeDescription
eventNamestring | symbolThe name of the event.
listener(…args: any[]) => voidThe callback function

Returns

this

Inherited from

client.prependOnceListener

Since

v6.0.0

Source

twitchfy/node_modules/@types/node/events.d.ts:850


rawListeners()

1
rawListeners(eventName: string | symbol): Function[]

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

1
import { EventEmitter } from 'node:events';
2
const emitter = new EventEmitter();
3
emitter.once('log', () => console.log('log once'));
4
5
// Returns a new Array with a function `onceWrapper` which has a property
6
// `listener` which contains the original listener bound above
7
const listeners = emitter.rawListeners('log');
8
const logFnWrapper = listeners[0];
9
10
// Logs "log once" to the console and does not unbind the `once` event
11
logFnWrapper.listener();
12
13
// Logs "log once" to the console and removes the listener
14
logFnWrapper();
15
16
emitter.on('log', () => console.log('log persistently'));
17
// Will return a new Array with a single function bound by `.on()` above
18
const newListeners = emitter.rawListeners('log');
19
20
// Logs "log persistently" twice
21
newListeners[0]();
22
emitter.emit('log');

Parameters

ParameterType
eventNamestring | symbol

Returns

Function[]

Inherited from

client.rawListeners

Since

v9.4.0

Source

twitchfy/node_modules/@types/node/events.d.ts:766


removeAllListeners()

1
removeAllListeners(event?: string | symbol): this

Removes all listeners, or those of the specified eventName.

It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

ParameterType
event?string | symbol

Returns

this

Inherited from

client.removeAllListeners

Since

v0.1.26

Source

twitchfy/node_modules/@types/node/events.d.ts:706


removeListener()

1
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this

Removes the specified listener from the listener array for the event namedeventName.

1
const callback = (stream) => {
2
console.log('someone connected!');
3
};
4
server.on('connection', callback);
5
// ...
6
server.removeListener('connection', callback);

removeListener() will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified eventName, then removeListener() must be called multiple times to remove each instance.

Once an event is emitted, all listeners attached to it at the time of emitting are called in order. This implies that anyremoveListener() or removeAllListeners() calls after emitting and before the last listener finishes execution will not remove them fromemit() in progress. Subsequent events behave as expected.

1
import { EventEmitter } from 'node:events';
2
class MyEmitter extends EventEmitter {}
3
const myEmitter = new MyEmitter();
4
5
const callbackA = () => {
6
console.log('A');
7
myEmitter.removeListener('event', callbackB);
8
};
9
10
const callbackB = () => {
11
console.log('B');
12
};
13
14
myEmitter.on('event', callbackA);
15
16
myEmitter.on('event', callbackB);
17
18
// callbackA removes listener callbackB but it will still be called.
19
// Internal listener array at time of emit [callbackA, callbackB]
20
myEmitter.emit('event');
21
// Prints:
22
// A
23
// B
24
25
// callbackB is now removed.
26
// Internal listener array [callbackA]
27
myEmitter.emit('event');
28
// Prints:
29
// A

Because listeners are managed using an internal array, calling this will change the position indices of any listener registered after the listener being removed. This will not impact the order in which listeners are called, but it means that any copies of the listener array as returned by the emitter.listeners() method will need to be recreated.

When a single function has been added as a handler multiple times for a single event (as in the example below), removeListener() will remove the most recently added instance. In the example the once('ping')listener is removed:

1
import { EventEmitter } from 'node:events';
2
const ee = new EventEmitter();
3
4
function pong() {
5
console.log('pong');
6
}
7
8
ee.on('ping', pong);
9
ee.once('ping', pong);
10
ee.removeListener('ping', pong);
11
12
ee.emit('ping');
13
ee.emit('ping');

Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

ParameterType
eventNamestring | symbol
listener(…args: any[]) => void

Returns

this

Inherited from

client.removeListener

Since

v0.1.26

Source

twitchfy/node_modules/@types/node/events.d.ts:690


setMaxListeners()

1
setMaxListeners(n: number): this

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set toInfinity (or 0) to indicate an unlimited number of listeners.

Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

ParameterType
nnumber

Returns

this

Inherited from

client.setMaxListeners

Since

v0.3.5

Source

twitchfy/node_modules/@types/node/events.d.ts:716


addAbortListener()

Experimental

1
static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable

Listens once to the abort event on the provided signal.

Listening to the abort event on abort signals is unsafe and may lead to resource leaks since another third party with the signal can call e.stopImmediatePropagation(). Unfortunately Node.js cannot change this since it would violate the web standard. Additionally, the original API makes it easy to forget to remove listeners.

This API allows safely using AbortSignals in Node.js APIs by solving these two issues by listening to the event such that stopImmediatePropagation does not prevent the listener from running.

Returns a disposable so that it may be unsubscribed from more easily.

1
import { addAbortListener } from 'node:events';
2
3
function example(signal) {
4
let disposable;
5
try {
6
signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
7
disposable = addAbortListener(signal, (e) => {
8
// Do something when signal is aborted.
9
});
10
} finally {
11
disposable?.[Symbol.dispose]();
12
}
13
}

Parameters

ParameterType
signalAbortSignal
resource(event: Event) => void

Returns

Disposable

Disposable that removes the abort listener.

Inherited from

client.addAbortListener

Since

v20.5.0

Source

twitchfy/node_modules/@types/node/events.d.ts:387


getEventListeners()

1
static getEventListeners(emitter: EventEmitter | _DOMEventTarget, name: string | symbol): Function[]

Returns a copy of the array of listeners for the event named eventName.

For EventEmitters this behaves exactly the same as calling .listeners on the emitter.

For EventTargets this is the only way to get the event listeners for the event target. This is useful for debugging and diagnostic purposes.

1
import { getEventListeners, EventEmitter } from 'node:events';
2
3
{
4
const ee = new EventEmitter();
5
const listener = () => console.log('Events are fun');
6
ee.on('foo', listener);
7
console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
8
}
9
{
10
const et = new EventTarget();
11
const listener = () => console.log('Events are fun');
12
et.addEventListener('foo', listener);
13
console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
14
}

Parameters

ParameterType
emitterEventEmitter | _DOMEventTarget
namestring | symbol

Returns

Function[]

Inherited from

client.getEventListeners

Since

v15.2.0, v14.17.0

Source

twitchfy/node_modules/@types/node/events.d.ts:308


getMaxListeners()

1
static getMaxListeners(emitter: EventEmitter | _DOMEventTarget): number

Returns the currently set max amount of listeners.

For EventEmitters this behaves exactly the same as calling .getMaxListeners on the emitter.

For EventTargets this is the only way to get the max event listeners for the event target. If the number of event handlers on a single EventTarget exceeds the max set, the EventTarget will print a warning.

1
import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
2
3
{
4
const ee = new EventEmitter();
5
console.log(getMaxListeners(ee)); // 10
6
setMaxListeners(11, ee);
7
console.log(getMaxListeners(ee)); // 11
8
}
9
{
10
const et = new EventTarget();
11
console.log(getMaxListeners(et)); // 10
12
setMaxListeners(11, et);
13
console.log(getMaxListeners(et)); // 11
14
}

Parameters

ParameterType
emitterEventEmitter | _DOMEventTarget

Returns

number

Inherited from

client.getMaxListeners

Since

v19.9.0

Source

twitchfy/node_modules/@types/node/events.d.ts:337


listenerCount()

1
static listenerCount(emitter: EventEmitter, eventName: string | symbol): number

A class method that returns the number of listeners for the given eventNameregistered on the given emitter.

1
import { EventEmitter, listenerCount } from 'node:events';
2
3
const myEmitter = new EventEmitter();
4
myEmitter.on('event', () => {});
5
myEmitter.on('event', () => {});
6
console.log(listenerCount(myEmitter, 'event'));
7
// Prints: 2

Parameters

ParameterTypeDescription
emitterEventEmitterThe emitter to query
eventNamestring | symbolThe event name

Returns

number

Inherited from

client.listenerCount

Since

v0.9.12

Source

twitchfy/node_modules/@types/node/events.d.ts:280


on()

1
static on(
2
emitter: EventEmitter,
3
eventName: string,
4
options?: StaticEventEmitterOptions): AsyncIterableIterator<any>
1
import { on, EventEmitter } from 'node:events';
2
import process from 'node:process';
3
4
const ee = new EventEmitter();
5
6
// Emit later on
7
process.nextTick(() => {
8
ee.emit('foo', 'bar');
9
ee.emit('foo', 42);
10
});
11
12
for await (const event of on(ee, 'foo')) {
13
// The execution of this inner block is synchronous and it
14
// processes one event at a time (even with await). Do not use
15
// if concurrent execution is required.
16
console.log(event); // prints ['bar'] [42]
17
}
18
// Unreachable here

Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

An AbortSignal can be used to cancel waiting on events:

1
import { on, EventEmitter } from 'node:events';
2
import process from 'node:process';
3
4
const ac = new AbortController();
5
6
(async () => {
7
const ee = new EventEmitter();
8
9
// Emit later on
10
process.nextTick(() => {
11
ee.emit('foo', 'bar');
12
ee.emit('foo', 42);
13
});
14
15
for await (const event of on(ee, 'foo', { signal: ac.signal })) {
16
// The execution of this inner block is synchronous and it
17
// processes one event at a time (even with await). Do not use
18
// if concurrent execution is required.
19
console.log(event); // prints ['bar'] [42]
20
}
21
// Unreachable here
22
})();
23
24
process.nextTick(() => ac.abort());

Parameters

ParameterTypeDescription
emitterEventEmitter-
eventNamestringThe name of the event being listened for
options?StaticEventEmitterOptions-

Returns

AsyncIterableIterator<any>

that iterates eventName events emitted by the emitter

Inherited from

client.on

Since

v13.6.0, v12.16.0

Source

twitchfy/node_modules/@types/node/events.d.ts:258


once()

once(emitter, eventName, options)

1
static once(
2
emitter: _NodeEventTarget,
3
eventName: string | symbol,
4
options?: StaticEventEmitterOptions): Promise<any[]>

Creates a Promise that is fulfilled when the EventEmitter emits the given event or that is rejected if the EventEmitter emits 'error' while waiting. The Promise will resolve with an array of all the arguments emitted to the given event.

This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event semantics and does not listen to the 'error' event.

1
import { once, EventEmitter } from 'node:events';
2
import process from 'node:process';
3
4
const ee = new EventEmitter();
5
6
process.nextTick(() => {
7
ee.emit('myevent', 42);
8
});
9
10
const [value] = await once(ee, 'myevent');
11
console.log(value);
12
13
const err = new Error('kaboom');
14
process.nextTick(() => {
15
ee.emit('error', err);
16
});
17
18
try {
19
await once(ee, 'myevent');
20
} catch (err) {
21
console.error('error happened', err);
22
}

The special handling of the 'error' event is only used when events.once()is used to wait for another event. If events.once() is used to wait for the ‘error' event itself, then it is treated as any other kind of event without special handling:

1
import { EventEmitter, once } from 'node:events';
2
3
const ee = new EventEmitter();
4
5
once(ee, 'error')
6
.then(([err]) => console.log('ok', err.message))
7
.catch((err) => console.error('error', err.message));
8
9
ee.emit('error', new Error('boom'));
10
11
// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

1
import { EventEmitter, once } from 'node:events';
2
3
const ee = new EventEmitter();
4
const ac = new AbortController();
5
6
async function foo(emitter, event, signal) {
7
try {
8
await once(emitter, event, { signal });
9
console.log('event emitted!');
10
} catch (error) {
11
if (error.name === 'AbortError') {
12
console.error('Waiting for the event was canceled!');
13
} else {
14
console.error('There was an error', error.message);
15
}
16
}
17
}
18
19
foo(ee, 'foo', ac.signal);
20
ac.abort(); // Abort waiting for the event
21
ee.emit('foo'); // Prints: Waiting for the event was canceled!
Parameters
ParameterType
emitter_NodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions
Returns

Promise<any[]>

Inherited from

client.once

Since

v11.13.0, v10.16.0

Source

twitchfy/node_modules/@types/node/events.d.ts:193

once(emitter, eventName, options)

1
static once(
2
emitter: _DOMEventTarget,
3
eventName: string,
4
options?: StaticEventEmitterOptions): Promise<any[]>
Parameters
ParameterType
emitter_DOMEventTarget
eventNamestring
options?StaticEventEmitterOptions
Returns

Promise<any[]>

Inherited from

client.once

Source

twitchfy/node_modules/@types/node/events.d.ts:198


setMaxListeners()

1
static setMaxListeners(n?: number, ...eventTargets?: (EventEmitter | _DOMEventTarget)[]): void
1
import { setMaxListeners, EventEmitter } from 'node:events';
2
3
const target = new EventTarget();
4
const emitter = new EventEmitter();
5
6
setMaxListeners(5, target, emitter);

Parameters

ParameterTypeDescription
n?numberA non-negative number. The maximum number of listeners per EventTarget event.
eventTargets?(EventEmitter | _DOMEventTarget)[]-

Returns

void

Inherited from

client.setMaxListeners

Since

v15.4.0

Source

twitchfy/node_modules/@types/node/events.d.ts:352