dualsense-ts 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1158 @@
1
+ # Class: DualsenseHID
2
+
3
+ ## Hierarchy
4
+
5
+ - `EventEmitter`
6
+
7
+ ↳ **`DualsenseHID`**
8
+
9
+ ## Table of contents
10
+
11
+ ### Constructors
12
+
13
+ - [constructor](../wiki/DualsenseHID#constructor)
14
+
15
+ ### Properties
16
+
17
+ - [state](../wiki/DualsenseHID#state)
18
+ - [captureRejectionSymbol](../wiki/DualsenseHID#capturerejectionsymbol)
19
+ - [captureRejections](../wiki/DualsenseHID#capturerejections)
20
+ - [defaultMaxListeners](../wiki/DualsenseHID#defaultmaxlisteners)
21
+ - [errorMonitor](../wiki/DualsenseHID#errormonitor)
22
+ - [productId](../wiki/DualsenseHID#productid)
23
+ - [vendorId](../wiki/DualsenseHID#vendorid)
24
+
25
+ ### Methods
26
+
27
+ - [addListener](../wiki/DualsenseHID#addlistener)
28
+ - [emit](../wiki/DualsenseHID#emit)
29
+ - [eventNames](../wiki/DualsenseHID#eventnames)
30
+ - [getMaxListeners](../wiki/DualsenseHID#getmaxlisteners)
31
+ - [listenerCount](../wiki/DualsenseHID#listenercount)
32
+ - [listeners](../wiki/DualsenseHID#listeners)
33
+ - [off](../wiki/DualsenseHID#off)
34
+ - [on](../wiki/DualsenseHID#on)
35
+ - [once](../wiki/DualsenseHID#once)
36
+ - [prependListener](../wiki/DualsenseHID#prependlistener)
37
+ - [prependOnceListener](../wiki/DualsenseHID#prependoncelistener)
38
+ - [rawListeners](../wiki/DualsenseHID#rawlisteners)
39
+ - [removeAllListeners](../wiki/DualsenseHID#removealllisteners)
40
+ - [removeListener](../wiki/DualsenseHID#removelistener)
41
+ - [setMaxListeners](../wiki/DualsenseHID#setmaxlisteners)
42
+ - [getEventListeners](../wiki/DualsenseHID#geteventlisteners)
43
+ - [listenerCount](../wiki/DualsenseHID#listenercount-1)
44
+ - [on](../wiki/DualsenseHID#on-1)
45
+ - [once](../wiki/DualsenseHID#once-1)
46
+ - [setMaxListeners](../wiki/DualsenseHID#setmaxlisteners-1)
47
+
48
+ ## Constructors
49
+
50
+ ### constructor
51
+
52
+ • **new DualsenseHID**()
53
+
54
+ #### Overrides
55
+
56
+ EventEmitter.constructor
57
+
58
+ #### Defined in
59
+
60
+ [src/hid/dualsense_hid.ts:111](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/hid/dualsense_hid.ts#L111)
61
+
62
+ ## Properties
63
+
64
+ ### state
65
+
66
+ • **state**: [`DualsenseHIDState`](../wiki/DualsenseHIDState)
67
+
68
+ #### Defined in
69
+
70
+ [src/hid/dualsense_hid.ts:61](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/hid/dualsense_hid.ts#L61)
71
+
72
+ ___
73
+
74
+ ### captureRejectionSymbol
75
+
76
+ ▪ `Static` `Readonly` **captureRejectionSymbol**: typeof [`captureRejectionSymbol`](../wiki/Dualsense#capturerejectionsymbol)
77
+
78
+ #### Inherited from
79
+
80
+ EventEmitter.captureRejectionSymbol
81
+
82
+ #### Defined in
83
+
84
+ node_modules/@types/node/events.d.ts:301
85
+
86
+ ___
87
+
88
+ ### captureRejections
89
+
90
+ ▪ `Static` **captureRejections**: `boolean`
91
+
92
+ Sets or gets the default captureRejection value for all emitters.
93
+
94
+ #### Inherited from
95
+
96
+ EventEmitter.captureRejections
97
+
98
+ #### Defined in
99
+
100
+ node_modules/@types/node/events.d.ts:306
101
+
102
+ ___
103
+
104
+ ### defaultMaxListeners
105
+
106
+ ▪ `Static` **defaultMaxListeners**: `number`
107
+
108
+ #### Inherited from
109
+
110
+ EventEmitter.defaultMaxListeners
111
+
112
+ #### Defined in
113
+
114
+ node_modules/@types/node/events.d.ts:307
115
+
116
+ ___
117
+
118
+ ### errorMonitor
119
+
120
+ ▪ `Static` `Readonly` **errorMonitor**: typeof [`errorMonitor`](../wiki/Dualsense#errormonitor)
121
+
122
+ This symbol shall be used to install a listener for only monitoring `'error'`
123
+ events. Listeners installed using this symbol are called before the regular
124
+ `'error'` listeners are called.
125
+
126
+ Installing a listener using this symbol does not change the behavior once an
127
+ `'error'` event is emitted, therefore the process will still crash if no
128
+ regular `'error'` listener is installed.
129
+
130
+ #### Inherited from
131
+
132
+ EventEmitter.errorMonitor
133
+
134
+ #### Defined in
135
+
136
+ node_modules/@types/node/events.d.ts:300
137
+
138
+ ___
139
+
140
+ ### productId
141
+
142
+ ▪ `Static` `Readonly` **productId**: `number` = `3302`
143
+
144
+ #### Defined in
145
+
146
+ [src/hid/dualsense_hid.ts:109](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/hid/dualsense_hid.ts#L109)
147
+
148
+ ___
149
+
150
+ ### vendorId
151
+
152
+ ▪ `Static` `Readonly` **vendorId**: `number` = `1356`
153
+
154
+ #### Defined in
155
+
156
+ [src/hid/dualsense_hid.ts:108](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/hid/dualsense_hid.ts#L108)
157
+
158
+ ## Methods
159
+
160
+ ### addListener
161
+
162
+ ▸ **addListener**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
163
+
164
+ Alias for `emitter.on(eventName, listener)`.
165
+
166
+ **`since`** v0.1.26
167
+
168
+ #### Parameters
169
+
170
+ | Name | Type |
171
+ | :------ | :------ |
172
+ | `eventName` | `string` \| `symbol` |
173
+ | `listener` | (...`args`: `any`[]) => `void` |
174
+
175
+ #### Returns
176
+
177
+ [`DualsenseHID`](../wiki/DualsenseHID)
178
+
179
+ #### Inherited from
180
+
181
+ EventEmitter.addListener
182
+
183
+ #### Defined in
184
+
185
+ node_modules/@types/node/events.d.ts:327
186
+
187
+ ___
188
+
189
+ ### emit
190
+
191
+ ▸ **emit**(`eventName`, ...`args`): `boolean`
192
+
193
+ Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
194
+ to each.
195
+
196
+ Returns `true` if the event had listeners, `false` otherwise.
197
+
198
+ ```js
199
+ const EventEmitter = require('events');
200
+ const myEmitter = new EventEmitter();
201
+
202
+ // First listener
203
+ myEmitter.on('event', function firstListener() {
204
+ console.log('Helloooo! first listener');
205
+ });
206
+ // Second listener
207
+ myEmitter.on('event', function secondListener(arg1, arg2) {
208
+ console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
209
+ });
210
+ // Third listener
211
+ myEmitter.on('event', function thirdListener(...args) {
212
+ const parameters = args.join(', ');
213
+ console.log(`event with parameters ${parameters} in third listener`);
214
+ });
215
+
216
+ console.log(myEmitter.listeners('event'));
217
+
218
+ myEmitter.emit('event', 1, 2, 3, 4, 5);
219
+
220
+ // Prints:
221
+ // [
222
+ // [Function: firstListener],
223
+ // [Function: secondListener],
224
+ // [Function: thirdListener]
225
+ // ]
226
+ // Helloooo! first listener
227
+ // event with parameters 1, 2 in second listener
228
+ // event with parameters 1, 2, 3, 4, 5 in third listener
229
+ ```
230
+
231
+ **`since`** v0.1.26
232
+
233
+ #### Parameters
234
+
235
+ | Name | Type |
236
+ | :------ | :------ |
237
+ | `eventName` | `string` \| `symbol` |
238
+ | `...args` | `any`[] |
239
+
240
+ #### Returns
241
+
242
+ `boolean`
243
+
244
+ #### Inherited from
245
+
246
+ EventEmitter.emit
247
+
248
+ #### Defined in
249
+
250
+ node_modules/@types/node/events.d.ts:583
251
+
252
+ ___
253
+
254
+ ### eventNames
255
+
256
+ ▸ **eventNames**(): (`string` \| `symbol`)[]
257
+
258
+ Returns an array listing the events for which the emitter has registered
259
+ listeners. The values in the array are strings or `Symbol`s.
260
+
261
+ ```js
262
+ const EventEmitter = require('events');
263
+ const myEE = new EventEmitter();
264
+ myEE.on('foo', () => {});
265
+ myEE.on('bar', () => {});
266
+
267
+ const sym = Symbol('symbol');
268
+ myEE.on(sym, () => {});
269
+
270
+ console.log(myEE.eventNames());
271
+ // Prints: [ 'foo', 'bar', Symbol(symbol) ]
272
+ ```
273
+
274
+ **`since`** v6.0.0
275
+
276
+ #### Returns
277
+
278
+ (`string` \| `symbol`)[]
279
+
280
+ #### Inherited from
281
+
282
+ EventEmitter.eventNames
283
+
284
+ #### Defined in
285
+
286
+ node_modules/@types/node/events.d.ts:642
287
+
288
+ ___
289
+
290
+ ### getMaxListeners
291
+
292
+ ▸ **getMaxListeners**(): `number`
293
+
294
+ Returns the current max listener value for the `EventEmitter` which is either
295
+ set by `emitter.setMaxListeners(n)` or defaults to [defaultMaxListeners](../wiki/DualsenseHID#defaultmaxlisteners).
296
+
297
+ **`since`** v1.0.0
298
+
299
+ #### Returns
300
+
301
+ `number`
302
+
303
+ #### Inherited from
304
+
305
+ EventEmitter.getMaxListeners
306
+
307
+ #### Defined in
308
+
309
+ node_modules/@types/node/events.d.ts:499
310
+
311
+ ___
312
+
313
+ ### listenerCount
314
+
315
+ ▸ **listenerCount**(`eventName`): `number`
316
+
317
+ Returns the number of listeners listening to the event named `eventName`.
318
+
319
+ **`since`** v3.2.0
320
+
321
+ #### Parameters
322
+
323
+ | Name | Type | Description |
324
+ | :------ | :------ | :------ |
325
+ | `eventName` | `string` \| `symbol` | The name of the event being listened for |
326
+
327
+ #### Returns
328
+
329
+ `number`
330
+
331
+ #### Inherited from
332
+
333
+ EventEmitter.listenerCount
334
+
335
+ #### Defined in
336
+
337
+ node_modules/@types/node/events.d.ts:589
338
+
339
+ ___
340
+
341
+ ### listeners
342
+
343
+ ▸ **listeners**(`eventName`): `Function`[]
344
+
345
+ Returns a copy of the array of listeners for the event named `eventName`.
346
+
347
+ ```js
348
+ server.on('connection', (stream) => {
349
+ console.log('someone connected!');
350
+ });
351
+ console.log(util.inspect(server.listeners('connection')));
352
+ // Prints: [ [Function] ]
353
+ ```
354
+
355
+ **`since`** v0.1.26
356
+
357
+ #### Parameters
358
+
359
+ | Name | Type |
360
+ | :------ | :------ |
361
+ | `eventName` | `string` \| `symbol` |
362
+
363
+ #### Returns
364
+
365
+ `Function`[]
366
+
367
+ #### Inherited from
368
+
369
+ EventEmitter.listeners
370
+
371
+ #### Defined in
372
+
373
+ node_modules/@types/node/events.d.ts:512
374
+
375
+ ___
376
+
377
+ ### off
378
+
379
+ ▸ **off**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
380
+
381
+ Alias for `emitter.removeListener()`.
382
+
383
+ **`since`** v10.0.0
384
+
385
+ #### Parameters
386
+
387
+ | Name | Type |
388
+ | :------ | :------ |
389
+ | `eventName` | `string` \| `symbol` |
390
+ | `listener` | (...`args`: `any`[]) => `void` |
391
+
392
+ #### Returns
393
+
394
+ [`DualsenseHID`](../wiki/DualsenseHID)
395
+
396
+ #### Inherited from
397
+
398
+ EventEmitter.off
399
+
400
+ #### Defined in
401
+
402
+ node_modules/@types/node/events.d.ts:472
403
+
404
+ ___
405
+
406
+ ### on
407
+
408
+ ▸ **on**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
409
+
410
+ Adds the `listener` function to the end of the listeners array for the
411
+ event named `eventName`. No checks are made to see if the `listener` has
412
+ already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
413
+ times.
414
+
415
+ ```js
416
+ server.on('connection', (stream) => {
417
+ console.log('someone connected!');
418
+ });
419
+ ```
420
+
421
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
422
+
423
+ By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
424
+ event listener to the beginning of the listeners array.
425
+
426
+ ```js
427
+ const myEE = new EventEmitter();
428
+ myEE.on('foo', () => console.log('a'));
429
+ myEE.prependListener('foo', () => console.log('b'));
430
+ myEE.emit('foo');
431
+ // Prints:
432
+ // b
433
+ // a
434
+ ```
435
+
436
+ **`since`** v0.1.101
437
+
438
+ #### Parameters
439
+
440
+ | Name | Type | Description |
441
+ | :------ | :------ | :------ |
442
+ | `eventName` | `string` \| `symbol` | The name of the event. |
443
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
444
+
445
+ #### Returns
446
+
447
+ [`DualsenseHID`](../wiki/DualsenseHID)
448
+
449
+ #### Inherited from
450
+
451
+ EventEmitter.on
452
+
453
+ #### Defined in
454
+
455
+ node_modules/@types/node/events.d.ts:358
456
+
457
+ ___
458
+
459
+ ### once
460
+
461
+ ▸ **once**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
462
+
463
+ Adds a **one-time**`listener` function for the event named `eventName`. The
464
+ next time `eventName` is triggered, this listener is removed and then invoked.
465
+
466
+ ```js
467
+ server.once('connection', (stream) => {
468
+ console.log('Ah, we have our first user!');
469
+ });
470
+ ```
471
+
472
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
473
+
474
+ 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
475
+ event listener to the beginning of the listeners array.
476
+
477
+ ```js
478
+ const myEE = new EventEmitter();
479
+ myEE.once('foo', () => console.log('a'));
480
+ myEE.prependOnceListener('foo', () => console.log('b'));
481
+ myEE.emit('foo');
482
+ // Prints:
483
+ // b
484
+ // a
485
+ ```
486
+
487
+ **`since`** v0.3.0
488
+
489
+ #### Parameters
490
+
491
+ | Name | Type | Description |
492
+ | :------ | :------ | :------ |
493
+ | `eventName` | `string` \| `symbol` | The name of the event. |
494
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
495
+
496
+ #### Returns
497
+
498
+ [`DualsenseHID`](../wiki/DualsenseHID)
499
+
500
+ #### Inherited from
501
+
502
+ EventEmitter.once
503
+
504
+ #### Defined in
505
+
506
+ node_modules/@types/node/events.d.ts:387
507
+
508
+ ___
509
+
510
+ ### prependListener
511
+
512
+ ▸ **prependListener**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
513
+
514
+ Adds the `listener` function to the _beginning_ of the listeners array for the
515
+ event named `eventName`. No checks are made to see if the `listener` has
516
+ already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
517
+ times.
518
+
519
+ ```js
520
+ server.prependListener('connection', (stream) => {
521
+ console.log('someone connected!');
522
+ });
523
+ ```
524
+
525
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
526
+
527
+ **`since`** v6.0.0
528
+
529
+ #### Parameters
530
+
531
+ | Name | Type | Description |
532
+ | :------ | :------ | :------ |
533
+ | `eventName` | `string` \| `symbol` | The name of the event. |
534
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
535
+
536
+ #### Returns
537
+
538
+ [`DualsenseHID`](../wiki/DualsenseHID)
539
+
540
+ #### Inherited from
541
+
542
+ EventEmitter.prependListener
543
+
544
+ #### Defined in
545
+
546
+ node_modules/@types/node/events.d.ts:607
547
+
548
+ ___
549
+
550
+ ### prependOnceListener
551
+
552
+ ▸ **prependOnceListener**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
553
+
554
+ Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
555
+ listener is removed, and then invoked.
556
+
557
+ ```js
558
+ server.prependOnceListener('connection', (stream) => {
559
+ console.log('Ah, we have our first user!');
560
+ });
561
+ ```
562
+
563
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
564
+
565
+ **`since`** v6.0.0
566
+
567
+ #### Parameters
568
+
569
+ | Name | Type | Description |
570
+ | :------ | :------ | :------ |
571
+ | `eventName` | `string` \| `symbol` | The name of the event. |
572
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
573
+
574
+ #### Returns
575
+
576
+ [`DualsenseHID`](../wiki/DualsenseHID)
577
+
578
+ #### Inherited from
579
+
580
+ EventEmitter.prependOnceListener
581
+
582
+ #### Defined in
583
+
584
+ node_modules/@types/node/events.d.ts:623
585
+
586
+ ___
587
+
588
+ ### rawListeners
589
+
590
+ ▸ **rawListeners**(`eventName`): `Function`[]
591
+
592
+ Returns a copy of the array of listeners for the event named `eventName`,
593
+ including any wrappers (such as those created by `.once()`).
594
+
595
+ ```js
596
+ const emitter = new EventEmitter();
597
+ emitter.once('log', () => console.log('log once'));
598
+
599
+ // Returns a new Array with a function `onceWrapper` which has a property
600
+ // `listener` which contains the original listener bound above
601
+ const listeners = emitter.rawListeners('log');
602
+ const logFnWrapper = listeners[0];
603
+
604
+ // Logs "log once" to the console and does not unbind the `once` event
605
+ logFnWrapper.listener();
606
+
607
+ // Logs "log once" to the console and removes the listener
608
+ logFnWrapper();
609
+
610
+ emitter.on('log', () => console.log('log persistently'));
611
+ // Will return a new Array with a single function bound by `.on()` above
612
+ const newListeners = emitter.rawListeners('log');
613
+
614
+ // Logs "log persistently" twice
615
+ newListeners[0]();
616
+ emitter.emit('log');
617
+ ```
618
+
619
+ **`since`** v9.4.0
620
+
621
+ #### Parameters
622
+
623
+ | Name | Type |
624
+ | :------ | :------ |
625
+ | `eventName` | `string` \| `symbol` |
626
+
627
+ #### Returns
628
+
629
+ `Function`[]
630
+
631
+ #### Inherited from
632
+
633
+ EventEmitter.rawListeners
634
+
635
+ #### Defined in
636
+
637
+ node_modules/@types/node/events.d.ts:542
638
+
639
+ ___
640
+
641
+ ### removeAllListeners
642
+
643
+ ▸ **removeAllListeners**(`event?`): [`DualsenseHID`](../wiki/DualsenseHID)
644
+
645
+ Removes all listeners, or those of the specified `eventName`.
646
+
647
+ It is bad practice to remove listeners added elsewhere in the code,
648
+ particularly when the `EventEmitter` instance was created by some other
649
+ component or module (e.g. sockets or file streams).
650
+
651
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
652
+
653
+ **`since`** v0.1.26
654
+
655
+ #### Parameters
656
+
657
+ | Name | Type |
658
+ | :------ | :------ |
659
+ | `event?` | `string` \| `symbol` |
660
+
661
+ #### Returns
662
+
663
+ [`DualsenseHID`](../wiki/DualsenseHID)
664
+
665
+ #### Inherited from
666
+
667
+ EventEmitter.removeAllListeners
668
+
669
+ #### Defined in
670
+
671
+ node_modules/@types/node/events.d.ts:483
672
+
673
+ ___
674
+
675
+ ### removeListener
676
+
677
+ ▸ **removeListener**(`eventName`, `listener`): [`DualsenseHID`](../wiki/DualsenseHID)
678
+
679
+ Removes the specified `listener` from the listener array for the event named`eventName`.
680
+
681
+ ```js
682
+ const callback = (stream) => {
683
+ console.log('someone connected!');
684
+ };
685
+ server.on('connection', callback);
686
+ // ...
687
+ server.removeListener('connection', callback);
688
+ ```
689
+
690
+ `removeListener()` will remove, at most, one instance of a listener from the
691
+ listener array. If any single listener has been added multiple times to the
692
+ listener array for the specified `eventName`, then `removeListener()` must be
693
+ called multiple times to remove each instance.
694
+
695
+ Once an event is emitted, all listeners attached to it at the
696
+ 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
697
+ not remove them from`emit()` in progress. Subsequent events behave as expected.
698
+
699
+ ```js
700
+ const myEmitter = new MyEmitter();
701
+
702
+ const callbackA = () => {
703
+ console.log('A');
704
+ myEmitter.removeListener('event', callbackB);
705
+ };
706
+
707
+ const callbackB = () => {
708
+ console.log('B');
709
+ };
710
+
711
+ myEmitter.on('event', callbackA);
712
+
713
+ myEmitter.on('event', callbackB);
714
+
715
+ // callbackA removes listener callbackB but it will still be called.
716
+ // Internal listener array at time of emit [callbackA, callbackB]
717
+ myEmitter.emit('event');
718
+ // Prints:
719
+ // A
720
+ // B
721
+
722
+ // callbackB is now removed.
723
+ // Internal listener array [callbackA]
724
+ myEmitter.emit('event');
725
+ // Prints:
726
+ // A
727
+ ```
728
+
729
+ Because listeners are managed using an internal array, calling this will
730
+ change the position indices of any listener registered _after_ the listener
731
+ being removed. This will not impact the order in which listeners are called,
732
+ but it means that any copies of the listener array as returned by
733
+ the `emitter.listeners()` method will need to be recreated.
734
+
735
+ When a single function has been added as a handler multiple times for a single
736
+ event (as in the example below), `removeListener()` will remove the most
737
+ recently added instance. In the example the `once('ping')`listener is removed:
738
+
739
+ ```js
740
+ const ee = new EventEmitter();
741
+
742
+ function pong() {
743
+ console.log('pong');
744
+ }
745
+
746
+ ee.on('ping', pong);
747
+ ee.once('ping', pong);
748
+ ee.removeListener('ping', pong);
749
+
750
+ ee.emit('ping');
751
+ ee.emit('ping');
752
+ ```
753
+
754
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
755
+
756
+ **`since`** v0.1.26
757
+
758
+ #### Parameters
759
+
760
+ | Name | Type |
761
+ | :------ | :------ |
762
+ | `eventName` | `string` \| `symbol` |
763
+ | `listener` | (...`args`: `any`[]) => `void` |
764
+
765
+ #### Returns
766
+
767
+ [`DualsenseHID`](../wiki/DualsenseHID)
768
+
769
+ #### Inherited from
770
+
771
+ EventEmitter.removeListener
772
+
773
+ #### Defined in
774
+
775
+ node_modules/@types/node/events.d.ts:467
776
+
777
+ ___
778
+
779
+ ### setMaxListeners
780
+
781
+ ▸ **setMaxListeners**(`n`): [`DualsenseHID`](../wiki/DualsenseHID)
782
+
783
+ By default `EventEmitter`s will print a warning if more than `10` listeners are
784
+ added for a particular event. This is a useful default that helps finding
785
+ memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
786
+ modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
787
+
788
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
789
+
790
+ **`since`** v0.3.5
791
+
792
+ #### Parameters
793
+
794
+ | Name | Type |
795
+ | :------ | :------ |
796
+ | `n` | `number` |
797
+
798
+ #### Returns
799
+
800
+ [`DualsenseHID`](../wiki/DualsenseHID)
801
+
802
+ #### Inherited from
803
+
804
+ EventEmitter.setMaxListeners
805
+
806
+ #### Defined in
807
+
808
+ node_modules/@types/node/events.d.ts:493
809
+
810
+ ___
811
+
812
+ ### getEventListeners
813
+
814
+ ▸ `Static` **getEventListeners**(`emitter`, `name`): `Function`[]
815
+
816
+ Returns a copy of the array of listeners for the event named `eventName`.
817
+
818
+ For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
819
+ the emitter.
820
+
821
+ For `EventTarget`s this is the only way to get the event listeners for the
822
+ event target. This is useful for debugging and diagnostic purposes.
823
+
824
+ ```js
825
+ const { getEventListeners, EventEmitter } = require('events');
826
+
827
+ {
828
+ const ee = new EventEmitter();
829
+ const listener = () => console.log('Events are fun');
830
+ ee.on('foo', listener);
831
+ getEventListeners(ee, 'foo'); // [listener]
832
+ }
833
+ {
834
+ const et = new EventTarget();
835
+ const listener = () => console.log('Events are fun');
836
+ et.addEventListener('foo', listener);
837
+ getEventListeners(et, 'foo'); // [listener]
838
+ }
839
+ ```
840
+
841
+ **`since`** v15.2.0, v14.17.0
842
+
843
+ #### Parameters
844
+
845
+ | Name | Type |
846
+ | :------ | :------ |
847
+ | `emitter` | `EventEmitter` \| `DOMEventTarget` |
848
+ | `name` | `string` \| `symbol` |
849
+
850
+ #### Returns
851
+
852
+ `Function`[]
853
+
854
+ #### Inherited from
855
+
856
+ EventEmitter.getEventListeners
857
+
858
+ #### Defined in
859
+
860
+ node_modules/@types/node/events.d.ts:270
861
+
862
+ ___
863
+
864
+ ### listenerCount
865
+
866
+ ▸ `Static` **listenerCount**(`emitter`, `eventName`): `number`
867
+
868
+ A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
869
+
870
+ ```js
871
+ const { EventEmitter, listenerCount } = require('events');
872
+ const myEmitter = new EventEmitter();
873
+ myEmitter.on('event', () => {});
874
+ myEmitter.on('event', () => {});
875
+ console.log(listenerCount(myEmitter, 'event'));
876
+ // Prints: 2
877
+ ```
878
+
879
+ **`since`** v0.9.12
880
+
881
+ **`deprecated`** Since v3.2.0 - Use `listenerCount` instead.
882
+
883
+ #### Parameters
884
+
885
+ | Name | Type | Description |
886
+ | :------ | :------ | :------ |
887
+ | `emitter` | `EventEmitter` | The emitter to query |
888
+ | `eventName` | `string` \| `symbol` | The event name |
889
+
890
+ #### Returns
891
+
892
+ `number`
893
+
894
+ #### Inherited from
895
+
896
+ EventEmitter.listenerCount
897
+
898
+ #### Defined in
899
+
900
+ node_modules/@types/node/events.d.ts:242
901
+
902
+ ___
903
+
904
+ ### on
905
+
906
+ ▸ `Static` **on**(`emitter`, `eventName`, `options?`): `AsyncIterableIterator`<`any`\>
907
+
908
+ ```js
909
+ const { on, EventEmitter } = require('events');
910
+
911
+ (async () => {
912
+ const ee = new EventEmitter();
913
+
914
+ // Emit later on
915
+ process.nextTick(() => {
916
+ ee.emit('foo', 'bar');
917
+ ee.emit('foo', 42);
918
+ });
919
+
920
+ for await (const event of on(ee, 'foo')) {
921
+ // The execution of this inner block is synchronous and it
922
+ // processes one event at a time (even with await). Do not use
923
+ // if concurrent execution is required.
924
+ console.log(event); // prints ['bar'] [42]
925
+ }
926
+ // Unreachable here
927
+ })();
928
+ ```
929
+
930
+ Returns an `AsyncIterator` that iterates `eventName` events. It will throw
931
+ if the `EventEmitter` emits `'error'`. It removes all listeners when
932
+ exiting the loop. The `value` returned by each iteration is an array
933
+ composed of the emitted event arguments.
934
+
935
+ An `AbortSignal` can be used to cancel waiting on events:
936
+
937
+ ```js
938
+ const { on, EventEmitter } = require('events');
939
+ const ac = new AbortController();
940
+
941
+ (async () => {
942
+ const ee = new EventEmitter();
943
+
944
+ // Emit later on
945
+ process.nextTick(() => {
946
+ ee.emit('foo', 'bar');
947
+ ee.emit('foo', 42);
948
+ });
949
+
950
+ for await (const event of on(ee, 'foo', { signal: ac.signal })) {
951
+ // The execution of this inner block is synchronous and it
952
+ // processes one event at a time (even with await). Do not use
953
+ // if concurrent execution is required.
954
+ console.log(event); // prints ['bar'] [42]
955
+ }
956
+ // Unreachable here
957
+ })();
958
+
959
+ process.nextTick(() => ac.abort());
960
+ ```
961
+
962
+ **`since`** v13.6.0, v12.16.0
963
+
964
+ #### Parameters
965
+
966
+ | Name | Type | Description |
967
+ | :------ | :------ | :------ |
968
+ | `emitter` | `EventEmitter` | - |
969
+ | `eventName` | `string` | The name of the event being listened for |
970
+ | `options?` | `StaticEventEmitterOptions` | - |
971
+
972
+ #### Returns
973
+
974
+ `AsyncIterableIterator`<`any`\>
975
+
976
+ that iterates `eventName` events emitted by the `emitter`
977
+
978
+ #### Inherited from
979
+
980
+ EventEmitter.on
981
+
982
+ #### Defined in
983
+
984
+ node_modules/@types/node/events.d.ts:221
985
+
986
+ ___
987
+
988
+ ### once
989
+
990
+ ▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
991
+
992
+ Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
993
+ event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
994
+ The `Promise` will resolve with an array of all the arguments emitted to the
995
+ given event.
996
+
997
+ This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
998
+ semantics and does not listen to the `'error'` event.
999
+
1000
+ ```js
1001
+ const { once, EventEmitter } = require('events');
1002
+
1003
+ async function run() {
1004
+ const ee = new EventEmitter();
1005
+
1006
+ process.nextTick(() => {
1007
+ ee.emit('myevent', 42);
1008
+ });
1009
+
1010
+ const [value] = await once(ee, 'myevent');
1011
+ console.log(value);
1012
+
1013
+ const err = new Error('kaboom');
1014
+ process.nextTick(() => {
1015
+ ee.emit('error', err);
1016
+ });
1017
+
1018
+ try {
1019
+ await once(ee, 'myevent');
1020
+ } catch (err) {
1021
+ console.log('error happened', err);
1022
+ }
1023
+ }
1024
+
1025
+ run();
1026
+ ```
1027
+
1028
+ 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
1029
+ '`error'` event itself, then it is treated as any other kind of event without
1030
+ special handling:
1031
+
1032
+ ```js
1033
+ const { EventEmitter, once } = require('events');
1034
+
1035
+ const ee = new EventEmitter();
1036
+
1037
+ once(ee, 'error')
1038
+ .then(([err]) => console.log('ok', err.message))
1039
+ .catch((err) => console.log('error', err.message));
1040
+
1041
+ ee.emit('error', new Error('boom'));
1042
+
1043
+ // Prints: ok boom
1044
+ ```
1045
+
1046
+ An `AbortSignal` can be used to cancel waiting for the event:
1047
+
1048
+ ```js
1049
+ const { EventEmitter, once } = require('events');
1050
+
1051
+ const ee = new EventEmitter();
1052
+ const ac = new AbortController();
1053
+
1054
+ async function foo(emitter, event, signal) {
1055
+ try {
1056
+ await once(emitter, event, { signal });
1057
+ console.log('event emitted!');
1058
+ } catch (error) {
1059
+ if (error.name === 'AbortError') {
1060
+ console.error('Waiting for the event was canceled!');
1061
+ } else {
1062
+ console.error('There was an error', error.message);
1063
+ }
1064
+ }
1065
+ }
1066
+
1067
+ foo(ee, 'foo', ac.signal);
1068
+ ac.abort(); // Abort waiting for the event
1069
+ ee.emit('foo'); // Prints: Waiting for the event was canceled!
1070
+ ```
1071
+
1072
+ **`since`** v11.13.0, v10.16.0
1073
+
1074
+ #### Parameters
1075
+
1076
+ | Name | Type |
1077
+ | :------ | :------ |
1078
+ | `emitter` | `NodeEventTarget` |
1079
+ | `eventName` | `string` \| `symbol` |
1080
+ | `options?` | `StaticEventEmitterOptions` |
1081
+
1082
+ #### Returns
1083
+
1084
+ `Promise`<`any`[]\>
1085
+
1086
+ #### Inherited from
1087
+
1088
+ EventEmitter.once
1089
+
1090
+ #### Defined in
1091
+
1092
+ node_modules/@types/node/events.d.ts:157
1093
+
1094
+ ▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
1095
+
1096
+ #### Parameters
1097
+
1098
+ | Name | Type |
1099
+ | :------ | :------ |
1100
+ | `emitter` | `DOMEventTarget` |
1101
+ | `eventName` | `string` |
1102
+ | `options?` | `StaticEventEmitterOptions` |
1103
+
1104
+ #### Returns
1105
+
1106
+ `Promise`<`any`[]\>
1107
+
1108
+ #### Inherited from
1109
+
1110
+ EventEmitter.once
1111
+
1112
+ #### Defined in
1113
+
1114
+ node_modules/@types/node/events.d.ts:162
1115
+
1116
+ ___
1117
+
1118
+ ### setMaxListeners
1119
+
1120
+ ▸ `Static` **setMaxListeners**(`n?`, ...`eventTargets`): `void`
1121
+
1122
+ By default `EventEmitter`s will print a warning if more than `10` listeners are
1123
+ added for a particular event. This is a useful default that helps finding
1124
+ memory leaks. The `EventEmitter.setMaxListeners()` method allows the default limit to be
1125
+ modified (if eventTargets is empty) or modify the limit specified in every `EventTarget` | `EventEmitter` passed as arguments.
1126
+ The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
1127
+
1128
+ ```js
1129
+ EventEmitter.setMaxListeners(20);
1130
+ // Equivalent to
1131
+ EventEmitter.defaultMaxListeners = 20;
1132
+
1133
+ const eventTarget = new EventTarget();
1134
+ // Only way to increase limit for `EventTarget` instances
1135
+ // as these doesn't expose its own `setMaxListeners` method
1136
+ EventEmitter.setMaxListeners(20, eventTarget);
1137
+ ```
1138
+
1139
+ **`since`** v15.3.0, v14.17.0
1140
+
1141
+ #### Parameters
1142
+
1143
+ | Name | Type |
1144
+ | :------ | :------ |
1145
+ | `n?` | `number` |
1146
+ | `...eventTargets` | (`EventEmitter` \| `DOMEventTarget`)[] |
1147
+
1148
+ #### Returns
1149
+
1150
+ `void`
1151
+
1152
+ #### Inherited from
1153
+
1154
+ EventEmitter.setMaxListeners
1155
+
1156
+ #### Defined in
1157
+
1158
+ node_modules/@types/node/events.d.ts:290