WebSocketShardConnector
A WebSocket Shard Connector for connecting to Twitch WebSocket EventSub service.
Extends
client
Constructors
new WebSocketShardConnector()
1new WebSocketShardConnector(connection: WebSocketShard): WebSocketShardConnectorBuilds up a WebSocketShardConnector.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | WebSocketShard | The WebSocket Shard to connect to. |
Returns
Overrides
client.constructor
Source
twitchfy/packages/eventsub/src/structures/WebSocketShardConnector.ts:41
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
connection | readonly | WebSocketShard | The WebSocket Shard to connect to. | - |
connectionURL | public | string | The connection URL of the WebSocket server used. | - |
sessionId | readonly | string | The session id of the shard. | - |
wsConnection | public | connection | The WebSocket connection used. | - |
captureRejectionSymbol | readonly | typeof captureRejectionSymbol | Value: See how to write a custom Since v13.4.0, v12.16.0 | client.captureRejectionSymbol |
captureRejections | static | boolean | Value: boolean Change the default Since v13.4.0, v12.16.0 | client.captureRejections |
defaultMaxListeners | static | number | By default, a maximum of Take caution when setting the This is not a hard limit. The import { EventEmitter } from ‘node:events
’;The The emitted warning can be inspected with Since v0.11.2 | client.defaultMaxListeners |
errorMonitor | readonly | typeof errorMonitor | This symbol shall be used to install a listener for only monitoring Installing a listener using this symbol does not change the behavior once an Since v13.6.0, v12.17.0 | client.errorMonitor |
Methods
[captureRejectionSymbol]()?
1optional [captureRejectionSymbol]<K>(2 error: Error,3 event: string | symbol, ...4 args: AnyRest): voidType parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type |
|---|---|
error | Error |
event | string | symbol |
…args | AnyRest |
Returns
void
Inherited from
client.[captureRejectionSymbol]
Source
twitchfy/node_modules/@types/node/events.d.ts:136
abort()
1abort(): voidWill 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)
1addListener(event: "connect", cb: (connection: connection) => void): thisParameters
| Parameter | Type |
|---|---|
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)
1addListener(event: "connectFailed", cb: (err: Error) => void): thisParameters
| Parameter | Type |
|---|---|
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)
1addListener(event: "httpResponse", cb: (response: IncomingMessage, client: client) => void): thisParameters
| Parameter | Type |
|---|---|
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()
1connect(url?: string): Promise<void>Connects to the WebSocket server.
Parameters
| Parameter | Type | Description |
|---|---|---|
url? | string | The 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()
1emit<K>(eventName: string | symbol, ...args: AnyRest): booleanSynchronously 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.
1import { EventEmitter } from 'node:events';2const myEmitter = new EventEmitter();3
4// First listener5myEmitter.on('event', function firstListener() {6 console.log('Helloooo! first listener');7});8// Second listener9myEmitter.on('event', function secondListener(arg1, arg2) {10 console.log(`event with parameters ${arg1}, ${arg2} in second listener`);11});12// Third listener13myEmitter.on('event', function thirdListener(...args) {14 const parameters = args.join(', ');15 console.log(`event with parameters ${parameters} in third listener`);16});17
18console.log(myEmitter.listeners('event'));19
20myEmitter.emit('event', 1, 2, 3, 4, 5);21
22// Prints:23// [24// [Function: firstListener],25// [Function: secondListener],26// [Function: thirdListener]27// ]28// Helloooo! first listener29// event with parameters 1, 2 in second listener30// event with parameters 1, 2, 3, 4, 5 in third listenerType parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type |
|---|---|
eventName | string | symbol |
…args | AnyRest |
Returns
boolean
Inherited from
client.emit
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:858
eventNames()
1eventNames(): (string | symbol)[]Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbols.
1import { EventEmitter } from 'node:events';2
3const myEE = new EventEmitter();4myEE.on('foo', () => {});5myEE.on('bar', () => {});6
7const sym = Symbol('symbol');8myEE.on(sym, () => {});9
10console.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:921
getMaxListeners()
1getMaxListeners(): numberReturns the current max listener value for the EventEmitter which is either
set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.
Returns
number
Inherited from
client.getMaxListeners
Since
v1.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:773
listenerCount()
1listenerCount<K>(eventName: string | symbol, listener?: Function): numberReturns 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.
Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
eventName | string | symbol | The name of the event being listened for |
listener? | Function | The event handler function |
Returns
number
Inherited from
client.listenerCount
Since
v3.2.0
Source
twitchfy/node_modules/@types/node/events.d.ts:867
listeners()
1listeners<K>(eventName: string | symbol): Function[]Returns a copy of the array of listeners for the event named eventName.
1server.on('connection', (stream) => {2 console.log('someone connected!');3});4console.log(util.inspect(server.listeners('connection')));5// Prints: [ [Function] ]Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type |
|---|---|
eventName | string | symbol |
Returns
Function[]
Inherited from
client.listeners
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:786
off()
1off<K>(eventName: string | symbol, listener: (...args: any[]) => void): thisAlias for emitter.removeListener().
Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type |
|---|---|
eventName | string | symbol |
listener | (…args: any[]) => void |
Returns
this
Inherited from
client.off
Since
v10.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:746
on()
on(event, cb)
1on(event: "connect", cb: (connection: connection) => void): thisParameters
| Parameter | Type |
|---|---|
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)
1on(event: "connectFailed", cb: (err: Error) => void): thisParameters
| Parameter | Type |
|---|---|
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)
1on(event: "httpResponse", cb: (response: IncomingMessage, client: client) => void): thisParameters
| Parameter | Type |
|---|---|
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()
1once<K>(eventName: string | symbol, listener: (...args: any[]) => void): thisAdds a one-time listener function for the event named eventName. The
next time eventName is triggered, this listener is removed and then invoked.
1server.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. The emitter.prependOnceListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
1import { EventEmitter } from 'node:events';2const myEE = new EventEmitter();3myEE.once('foo', () => console.log('a'));4myEE.prependOnceListener('foo', () => console.log('b'));5myEE.emit('foo');6// Prints:7// b8// aType parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
eventName | string | symbol | The name of the event. |
listener | (…args: any[]) => void | The callback function |
Returns
this
Inherited from
client.once
Since
v0.3.0
Source
twitchfy/node_modules/@types/node/events.d.ts:658
prependListener()
1prependListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): thisAdds 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 eventName
and listener will result in the listener being added, and called, multiple times.
1server.prependListener('connection', (stream) => {2 console.log('someone connected!');3});Returns a reference to the EventEmitter, so that calls can be chained.
Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
eventName | string | symbol | The name of the event. |
listener | (…args: any[]) => void | The callback function |
Returns
this
Inherited from
client.prependListener
Since
v6.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:885
prependOnceListener()
1prependOnceListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): thisAdds 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.
1server.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.
Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
eventName | string | symbol | The name of the event. |
listener | (…args: any[]) => void | The callback function |
Returns
this
Inherited from
client.prependOnceListener
Since
v6.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:901
rawListeners()
1rawListeners<K>(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()).
1import { EventEmitter } from 'node:events';2const emitter = new EventEmitter();3emitter.once('log', () => console.log('log once'));4
5// Returns a new Array with a function `onceWrapper` which has a property6// `listener` which contains the original listener bound above7const listeners = emitter.rawListeners('log');8const logFnWrapper = listeners[0];9
10// Logs "log once" to the console and does not unbind the `once` event11logFnWrapper.listener();12
13// Logs "log once" to the console and removes the listener14logFnWrapper();15
16emitter.on('log', () => console.log('log persistently'));17// Will return a new Array with a single function bound by `.on()` above18const newListeners = emitter.rawListeners('log');19
20// Logs "log persistently" twice21newListeners[0]();22emitter.emit('log');Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type |
|---|---|
eventName | string | symbol |
Returns
Function[]
Inherited from
client.rawListeners
Since
v9.4.0
Source
twitchfy/node_modules/@types/node/events.d.ts:817
removeAllListeners()
1removeAllListeners(eventName?: string | symbol): thisRemoves 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
| Parameter | Type |
|---|---|
eventName? | string | symbol |
Returns
this
Inherited from
client.removeAllListeners
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:757
removeListener()
1removeListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): thisRemoves the specified listener from the listener array for the event named eventName.
1const callback = (stream) => {2 console.log('someone connected!');3};4server.on('connection', callback);5// ...6server.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 any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution
will not remove them fromemit() in progress. Subsequent events behave as expected.
1import { EventEmitter } from 'node:events';2class MyEmitter extends EventEmitter {}3const myEmitter = new MyEmitter();4
5const callbackA = () => {6 console.log('A');7 myEmitter.removeListener('event', callbackB);8};9
10const callbackB = () => {11 console.log('B');12};13
14myEmitter.on('event', callbackA);15
16myEmitter.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]20myEmitter.emit('event');21// Prints:22// A23// B24
25// callbackB is now removed.26// Internal listener array [callbackA]27myEmitter.emit('event');28// Prints:29// ABecause 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:
1import { EventEmitter } from 'node:events';2const ee = new EventEmitter();3
4function pong() {5 console.log('pong');6}7
8ee.on('ping', pong);9ee.once('ping', pong);10ee.removeListener('ping', pong);11
12ee.emit('ping');13ee.emit('ping');Returns a reference to the EventEmitter, so that calls can be chained.
Type parameters
| Type parameter |
|---|
K |
Parameters
| Parameter | Type |
|---|---|
eventName | string | symbol |
listener | (…args: any[]) => void |
Returns
this
Inherited from
client.removeListener
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:741
setMaxListeners()
1setMaxListeners(n: number): thisBy 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 to Infinity (or 0) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter, so that calls can be chained.
Parameters
| Parameter | Type |
|---|---|
n | number |
Returns
this
Inherited from
client.setMaxListeners
Since
v0.3.5
Source
twitchfy/node_modules/@types/node/events.d.ts:767
addAbortListener()
1static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): DisposableListens 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.
1import { addAbortListener } from 'node:events';2
3function 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
| Parameter | Type |
|---|---|
signal | AbortSignal |
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:436
getEventListeners()
1static getEventListeners(emitter: EventEmitter<DefaultEventMap> | EventTarget, 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.
1import { 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
| Parameter | Type |
|---|---|
emitter | EventEmitter<DefaultEventMap> | EventTarget |
name | string | symbol |
Returns
Function[]
Inherited from
client.getEventListeners
Since
v15.2.0, v14.17.0
Source
twitchfy/node_modules/@types/node/events.d.ts:358
getMaxListeners()
1static getMaxListeners(emitter: EventEmitter<DefaultEventMap> | EventTarget): numberReturns 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.
1import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';2
3{4 const ee = new EventEmitter();5 console.log(getMaxListeners(ee)); // 106 setMaxListeners(11, ee);7 console.log(getMaxListeners(ee)); // 118}9{10 const et = new EventTarget();11 console.log(getMaxListeners(et)); // 1012 setMaxListeners(11, et);13 console.log(getMaxListeners(et)); // 1114}Parameters
| Parameter | Type |
|---|---|
emitter | EventEmitter<DefaultEventMap> | EventTarget |
Returns
number
Inherited from
client.getMaxListeners
Since
v19.9.0
Source
twitchfy/node_modules/@types/node/events.d.ts:387
listenerCount()
1static listenerCount(emitter: EventEmitter<DefaultEventMap>, eventName: string | symbol): numberA class method that returns the number of listeners for the given eventName registered on the given emitter.
1import { EventEmitter, listenerCount } from 'node:events';2
3const myEmitter = new EventEmitter();4myEmitter.on('event', () => {});5myEmitter.on('event', () => {});6console.log(listenerCount(myEmitter, 'event'));7// Prints: 2Parameters
| Parameter | Type | Description |
|---|---|---|
emitter | EventEmitter<DefaultEventMap> | The emitter to query |
eventName | string | symbol | The event name |
Returns
number
Inherited from
client.listenerCount
Since
v0.9.12
Source
twitchfy/node_modules/@types/node/events.d.ts:330
on()
on(emitter, eventName, options)
1static on(2 emitter: EventEmitter<DefaultEventMap>,3 eventName: string | symbol,4options?: StaticEventEmitterIteratorOptions): AsyncIterator<any[], undefined, any>1import { on, EventEmitter } from 'node:events';2import process from 'node:process';3
4const ee = new EventEmitter();5
6// Emit later on7process.nextTick(() => {8 ee.emit('foo', 'bar');9 ee.emit('foo', 42);10});11
12for await (const event of on(ee, 'foo')) {13 // The execution of this inner block is synchronous and it14 // processes one event at a time (even with await). Do not use15 // if concurrent execution is required.16 console.log(event); // prints ['bar'] [42]17}18// Unreachable hereReturns 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:
1import { on, EventEmitter } from 'node:events';2import process from 'node:process';3
4const ac = new AbortController();5
6(async () => {7 const ee = new EventEmitter();8
9 // Emit later on10 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 it17 // processes one event at a time (even with await). Do not use18 // if concurrent execution is required.19 console.log(event); // prints ['bar'] [42]20 }21 // Unreachable here22})();23
24process.nextTick(() => ac.abort());Use the close option to specify an array of event names that will end the iteration:
1import { on, EventEmitter } from 'node:events';2import process from 'node:process';3
4const ee = new EventEmitter();5
6// Emit later on7process.nextTick(() => {8 ee.emit('foo', 'bar');9 ee.emit('foo', 42);10 ee.emit('close');11});12
13for await (const event of on(ee, 'foo', { close: ['close'] })) {14 console.log(event); // prints ['bar'] [42]15}16// the loop will exit after 'close' is emitted17console.log('done'); // prints 'done'Parameters
| Parameter | Type |
|---|---|
emitter | EventEmitter<DefaultEventMap> |
eventName | string | symbol |
options? | StaticEventEmitterIteratorOptions |
Returns
AsyncIterator<any[], undefined, any>
An AsyncIterator 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:303
on(emitter, eventName, options)
1static on(2 emitter: EventTarget,3 eventName: string,4options?: StaticEventEmitterIteratorOptions): AsyncIterator<any[], undefined, any>Parameters
| Parameter | Type |
|---|---|
emitter | EventTarget |
eventName | string |
options? | StaticEventEmitterIteratorOptions |
Returns
AsyncIterator<any[], undefined, any>
Inherited from
client.on
Source
twitchfy/node_modules/@types/node/events.d.ts:308
once()
once(emitter, eventName, options)
1static once(2 emitter: EventEmitter<DefaultEventMap>,3 eventName: string | symbol,4options?: 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.
1import { once, EventEmitter } from 'node:events';2import process from 'node:process';3
4const ee = new EventEmitter();5
6process.nextTick(() => {7 ee.emit('myevent', 42);8});9
10const [value] = await once(ee, 'myevent');11console.log(value);12
13const err = new Error('kaboom');14process.nextTick(() => {15 ee.emit('error', err);16});17
18try {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:
1import { EventEmitter, once } from 'node:events';2
3const ee = new EventEmitter();4
5once(ee, 'error')6 .then(([err]) => console.log('ok', err.message))7 .catch((err) => console.error('error', err.message));8
9ee.emit('error', new Error('boom'));10
11// Prints: ok boomAn AbortSignal can be used to cancel waiting for the event:
1import { EventEmitter, once } from 'node:events';2
3const ee = new EventEmitter();4const ac = new AbortController();5
6async 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
19foo(ee, 'foo', ac.signal);20ac.abort(); // Abort waiting for the event21ee.emit('foo'); // Prints: Waiting for the event was canceled!Parameters
| Parameter | Type |
|---|---|
emitter | EventEmitter<DefaultEventMap> |
eventName | string | 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:217
once(emitter, eventName, options)
1static once(2 emitter: EventTarget,3 eventName: string,4options?: StaticEventEmitterOptions): Promise<any[]>Parameters
| Parameter | Type |
|---|---|
emitter | EventTarget |
eventName | string |
options? | StaticEventEmitterOptions |
Returns
Promise<any[]>
Inherited from
client.once
Source
twitchfy/node_modules/@types/node/events.d.ts:222
setMaxListeners()
1static setMaxListeners(n?: number, ...eventTargets?: (EventEmitter<DefaultEventMap> | EventTarget)[]): void1import { setMaxListeners, EventEmitter } from 'node:events';2
3const target = new EventTarget();4const emitter = new EventEmitter();5
6setMaxListeners(5, target, emitter);Parameters
| Parameter | Type | Description |
|---|---|---|
n? | number | A non-negative number. The maximum number of listeners per EventTarget event. |
…eventTargets? | (EventEmitter<DefaultEventMap> | EventTarget)[] | Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} objects. |
Returns
void
Inherited from
client.setMaxListeners
Since
v15.4.0
Source
twitchfy/node_modules/@types/node/events.d.ts:402