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,1620 @@
1
+ # Class: Trigger
2
+
3
+ ## Hierarchy
4
+
5
+ - [`Input`](../wiki/Input)<[`Magnitude`](../wiki/Exports#magnitude)\>
6
+
7
+ ↳ **`Trigger`**
8
+
9
+ ## Table of contents
10
+
11
+ ### Constructors
12
+
13
+ - [constructor](../wiki/Trigger#constructor)
14
+
15
+ ### Properties
16
+
17
+ - [[InputChanged]](../wiki/Trigger#%5Binputchanged%5D)
18
+ - [[InputChildless]](../wiki/Trigger#%5Binputchildless%5D)
19
+ - [[InputIcon]](../wiki/Trigger#%5Binputicon%5D)
20
+ - [[InputName]](../wiki/Trigger#%5Binputname%5D)
21
+ - [[InputParent]](../wiki/Trigger#%5Binputparent%5D)
22
+ - [button](../wiki/Trigger#button)
23
+ - [haptic](../wiki/Trigger#haptic)
24
+ - [id](../wiki/Trigger#id)
25
+ - [lastChange](../wiki/Trigger#lastchange)
26
+ - [lastInput](../wiki/Trigger#lastinput)
27
+ - [state](../wiki/Trigger#state)
28
+ - [threshold](../wiki/Trigger#threshold)
29
+ - [captureRejectionSymbol](../wiki/Trigger#capturerejectionsymbol)
30
+ - [captureRejections](../wiki/Trigger#capturerejections)
31
+ - [defaultMaxListeners](../wiki/Trigger#defaultmaxlisteners)
32
+ - [errorMonitor](../wiki/Trigger#errormonitor)
33
+
34
+ ### Accessors
35
+
36
+ - [[toStringTag]](../wiki/Trigger#%5Btostringtag%5D)
37
+ - [active](../wiki/Trigger#active)
38
+ - [magnitude](../wiki/Trigger#magnitude)
39
+ - [pressure](../wiki/Trigger#pressure)
40
+
41
+ ### Methods
42
+
43
+ - [[InputAdopt]](../wiki/Trigger#%5Binputadopt%5D)
44
+ - [[InputChangedPrimitive]](../wiki/Trigger#%5Binputchangedprimitive%5D)
45
+ - [[InputChangedThreshold]](../wiki/Trigger#%5Binputchangedthreshold%5D)
46
+ - [[InputChangedVirtual]](../wiki/Trigger#%5Binputchangedvirtual%5D)
47
+ - [[InputSetComparison]](../wiki/Trigger#%5Binputsetcomparison%5D)
48
+ - [[InputSet]](../wiki/Trigger#%5Binputset%5D)
49
+ - [[asyncIterator]](../wiki/Trigger#%5Basynciterator%5D)
50
+ - [[custom]](../wiki/Trigger#%5Bcustom%5D)
51
+ - [[toPrimitive]](../wiki/Trigger#%5Btoprimitive%5D)
52
+ - [addListener](../wiki/Trigger#addlistener)
53
+ - [changes](../wiki/Trigger#changes)
54
+ - [emit](../wiki/Trigger#emit)
55
+ - [eventNames](../wiki/Trigger#eventnames)
56
+ - [getMaxListeners](../wiki/Trigger#getmaxlisteners)
57
+ - [listenerCount](../wiki/Trigger#listenercount)
58
+ - [listeners](../wiki/Trigger#listeners)
59
+ - [next](../wiki/Trigger#next)
60
+ - [off](../wiki/Trigger#off)
61
+ - [on](../wiki/Trigger#on)
62
+ - [once](../wiki/Trigger#once)
63
+ - [prependListener](../wiki/Trigger#prependlistener)
64
+ - [prependOnceListener](../wiki/Trigger#prependoncelistener)
65
+ - [promise](../wiki/Trigger#promise)
66
+ - [rawListeners](../wiki/Trigger#rawlisteners)
67
+ - [removeAllListeners](../wiki/Trigger#removealllisteners)
68
+ - [removeListener](../wiki/Trigger#removelistener)
69
+ - [setMaxListeners](../wiki/Trigger#setmaxlisteners)
70
+ - [toString](../wiki/Trigger#tostring)
71
+ - [getEventListeners](../wiki/Trigger#geteventlisteners)
72
+ - [listenerCount](../wiki/Trigger#listenercount-1)
73
+ - [on](../wiki/Trigger#on-1)
74
+ - [once](../wiki/Trigger#once-1)
75
+ - [setMaxListeners](../wiki/Trigger#setmaxlisteners-1)
76
+
77
+ ## Constructors
78
+
79
+ ### constructor
80
+
81
+ • **new Trigger**(`params?`)
82
+
83
+ #### Parameters
84
+
85
+ | Name | Type |
86
+ | :------ | :------ |
87
+ | `params?` | [`InputParams`](../wiki/InputParams) |
88
+
89
+ #### Inherited from
90
+
91
+ [Input](../wiki/Input).[constructor](../wiki/Input#constructor)
92
+
93
+ #### Defined in
94
+
95
+ [src/input.ts:102](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L102)
96
+
97
+ ## Properties
98
+
99
+ ### [InputChanged]
100
+
101
+ • **[InputChanged]**: (`state`: `number`, `newState`: `number`) => `boolean`
102
+
103
+ #### Type declaration
104
+
105
+ ▸ (`state`, `newState`): `boolean`
106
+
107
+ ##### Parameters
108
+
109
+ | Name | Type |
110
+ | :------ | :------ |
111
+ | `state` | `number` |
112
+ | `newState` | `number` |
113
+
114
+ ##### Returns
115
+
116
+ `boolean`
117
+
118
+ #### Inherited from
119
+
120
+ [Input](../wiki/Input).[[InputChanged]](../wiki/Input#%5Binputchanged%5D)
121
+
122
+ #### Defined in
123
+
124
+ [src/input.ts:124](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L124)
125
+
126
+ ___
127
+
128
+ ### [InputChildless]
129
+
130
+ • **[InputChildless]**: `boolean` = `true`
131
+
132
+ #### Inherited from
133
+
134
+ [Input](../wiki/Input).[[InputChildless]](../wiki/Input#%5Binputchildless%5D)
135
+
136
+ #### Defined in
137
+
138
+ [src/input.ts:158](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L158)
139
+
140
+ ___
141
+
142
+ ### [InputIcon]
143
+
144
+ • `Readonly` **[InputIcon]**: `string`
145
+
146
+ #### Inherited from
147
+
148
+ [Input](../wiki/Input).[[InputIcon]](../wiki/Input#%5Binputicon%5D)
149
+
150
+ #### Defined in
151
+
152
+ [src/input.ts:153](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L153)
153
+
154
+ ___
155
+
156
+ ### [InputName]
157
+
158
+ • `Readonly` **[InputName]**: `string`
159
+
160
+ #### Inherited from
161
+
162
+ [Input](../wiki/Input).[[InputName]](../wiki/Input#%5Binputname%5D)
163
+
164
+ #### Defined in
165
+
166
+ [src/input.ts:150](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L150)
167
+
168
+ ___
169
+
170
+ ### [InputParent]
171
+
172
+ • `Optional` **[InputParent]**: [`Input`](../wiki/Input)<`unknown`\>
173
+
174
+ #### Inherited from
175
+
176
+ [Input](../wiki/Input).[[InputParent]](../wiki/Input#%5Binputparent%5D)
177
+
178
+ #### Defined in
179
+
180
+ [src/input.ts:156](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L156)
181
+
182
+ ___
183
+
184
+ ### button
185
+
186
+ • **button**: [`Momentary`](../wiki/Momentary)
187
+
188
+ #### Defined in
189
+
190
+ [src/elements/trigger.ts:9](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L9)
191
+
192
+ ___
193
+
194
+ ### haptic
195
+
196
+ • `Readonly` **haptic**: [`Haptic`](../wiki/Haptic)
197
+
198
+ #### Defined in
199
+
200
+ [src/elements/trigger.ts:27](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L27)
201
+
202
+ ___
203
+
204
+ ### id
205
+
206
+ • `Readonly` **id**: `symbol`
207
+
208
+ #### Inherited from
209
+
210
+ [Input](../wiki/Input).[id](../wiki/Input#id)
211
+
212
+ #### Defined in
213
+
214
+ [src/input.ts:58](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L58)
215
+
216
+ ___
217
+
218
+ ### lastChange
219
+
220
+ • **lastChange**: `number`
221
+
222
+ #### Inherited from
223
+
224
+ [Input](../wiki/Input).[lastChange](../wiki/Input#lastchange)
225
+
226
+ #### Defined in
227
+
228
+ [src/input.ts:61](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L61)
229
+
230
+ ___
231
+
232
+ ### lastInput
233
+
234
+ • **lastInput**: `number`
235
+
236
+ #### Inherited from
237
+
238
+ [Input](../wiki/Input).[lastInput](../wiki/Input#lastinput)
239
+
240
+ #### Defined in
241
+
242
+ [src/input.ts:64](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L64)
243
+
244
+ ___
245
+
246
+ ### state
247
+
248
+ • **state**: `number` = `0`
249
+
250
+ #### Overrides
251
+
252
+ [Input](../wiki/Input).[state](../wiki/Input#state)
253
+
254
+ #### Defined in
255
+
256
+ [src/elements/trigger.ts:7](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L7)
257
+
258
+ ___
259
+
260
+ ### threshold
261
+
262
+ • **threshold**: `number` = `0`
263
+
264
+ #### Inherited from
265
+
266
+ [Input](../wiki/Input).[threshold](../wiki/Input#threshold)
267
+
268
+ #### Defined in
269
+
270
+ [src/input.ts:67](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L67)
271
+
272
+ ___
273
+
274
+ ### captureRejectionSymbol
275
+
276
+ ▪ `Static` `Readonly` **captureRejectionSymbol**: typeof [`captureRejectionSymbol`](../wiki/Dualsense#capturerejectionsymbol)
277
+
278
+ #### Inherited from
279
+
280
+ [Input](../wiki/Input).[captureRejectionSymbol](../wiki/Input#capturerejectionsymbol)
281
+
282
+ #### Defined in
283
+
284
+ node_modules/@types/node/events.d.ts:301
285
+
286
+ ___
287
+
288
+ ### captureRejections
289
+
290
+ ▪ `Static` **captureRejections**: `boolean`
291
+
292
+ Sets or gets the default captureRejection value for all emitters.
293
+
294
+ #### Inherited from
295
+
296
+ [Input](../wiki/Input).[captureRejections](../wiki/Input#capturerejections)
297
+
298
+ #### Defined in
299
+
300
+ node_modules/@types/node/events.d.ts:306
301
+
302
+ ___
303
+
304
+ ### defaultMaxListeners
305
+
306
+ ▪ `Static` **defaultMaxListeners**: `number`
307
+
308
+ #### Inherited from
309
+
310
+ [Input](../wiki/Input).[defaultMaxListeners](../wiki/Input#defaultmaxlisteners)
311
+
312
+ #### Defined in
313
+
314
+ node_modules/@types/node/events.d.ts:307
315
+
316
+ ___
317
+
318
+ ### errorMonitor
319
+
320
+ ▪ `Static` `Readonly` **errorMonitor**: typeof [`errorMonitor`](../wiki/Dualsense#errormonitor)
321
+
322
+ This symbol shall be used to install a listener for only monitoring `'error'`
323
+ events. Listeners installed using this symbol are called before the regular
324
+ `'error'` listeners are called.
325
+
326
+ Installing a listener using this symbol does not change the behavior once an
327
+ `'error'` event is emitted, therefore the process will still crash if no
328
+ regular `'error'` listener is installed.
329
+
330
+ #### Inherited from
331
+
332
+ [Input](../wiki/Input).[errorMonitor](../wiki/Input#errormonitor)
333
+
334
+ #### Defined in
335
+
336
+ node_modules/@types/node/events.d.ts:300
337
+
338
+ ## Accessors
339
+
340
+ ### [toStringTag]
341
+
342
+ • `get` **[toStringTag]**(): `string`
343
+
344
+ #### Returns
345
+
346
+ `string`
347
+
348
+ #### Inherited from
349
+
350
+ Input.\_\_@toStringTag@66
351
+
352
+ #### Defined in
353
+
354
+ [src/input.ts:145](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L145)
355
+
356
+ ___
357
+
358
+ ### active
359
+
360
+ • `get` **active**(): `boolean`
361
+
362
+ #### Returns
363
+
364
+ `boolean`
365
+
366
+ #### Overrides
367
+
368
+ Input.active
369
+
370
+ #### Defined in
371
+
372
+ [src/elements/trigger.ts:11](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L11)
373
+
374
+ ___
375
+
376
+ ### magnitude
377
+
378
+ • `get` **magnitude**(): `number`
379
+
380
+ #### Returns
381
+
382
+ `number`
383
+
384
+ #### Defined in
385
+
386
+ [src/elements/trigger.ts:19](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L19)
387
+
388
+ ___
389
+
390
+ ### pressure
391
+
392
+ • `get` **pressure**(): `number`
393
+
394
+ #### Returns
395
+
396
+ `number`
397
+
398
+ #### Defined in
399
+
400
+ [src/elements/trigger.ts:15](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L15)
401
+
402
+ ## Methods
403
+
404
+ ### [InputAdopt]
405
+
406
+ ▸ **[InputAdopt]**(): `void`
407
+
408
+ Cascade events from nested Inputs.
409
+ And decide if this is the root Input.
410
+
411
+ #### Returns
412
+
413
+ `void`
414
+
415
+ #### Inherited from
416
+
417
+ [Input](../wiki/Input).[[InputAdopt]](../wiki/Input#%5Binputadopt%5D)
418
+
419
+ #### Defined in
420
+
421
+ [src/input.ts:164](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L164)
422
+
423
+ ___
424
+
425
+ ### [InputChangedPrimitive]
426
+
427
+ ▸ **[InputChangedPrimitive]**(`state`, `newState`): `boolean`
428
+
429
+ #### Parameters
430
+
431
+ | Name | Type |
432
+ | :------ | :------ |
433
+ | `state` | `number` |
434
+ | `newState` | `number` |
435
+
436
+ #### Returns
437
+
438
+ `boolean`
439
+
440
+ #### Inherited from
441
+
442
+ [Input](../wiki/Input).[[InputChangedPrimitive]](../wiki/Input#%5Binputchangedprimitive%5D)
443
+
444
+ #### Defined in
445
+
446
+ [src/input.ts:186](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L186)
447
+
448
+ ___
449
+
450
+ ### [InputChangedThreshold]
451
+
452
+ ▸ **[InputChangedThreshold]**(`state`, `newState`): `boolean`
453
+
454
+ #### Parameters
455
+
456
+ | Name | Type |
457
+ | :------ | :------ |
458
+ | `state` | `number` |
459
+ | `newState` | `number` |
460
+
461
+ #### Returns
462
+
463
+ `boolean`
464
+
465
+ #### Inherited from
466
+
467
+ [Input](../wiki/Input).[[InputChangedThreshold]](../wiki/Input#%5Binputchangedthreshold%5D)
468
+
469
+ #### Defined in
470
+
471
+ [src/input.ts:190](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L190)
472
+
473
+ ___
474
+
475
+ ### [InputChangedVirtual]
476
+
477
+ ▸ **[InputChangedVirtual]**(): `boolean`
478
+
479
+ #### Returns
480
+
481
+ `boolean`
482
+
483
+ #### Inherited from
484
+
485
+ [Input](../wiki/Input).[[InputChangedVirtual]](../wiki/Input#%5Binputchangedvirtual%5D)
486
+
487
+ #### Defined in
488
+
489
+ [src/input.ts:182](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L182)
490
+
491
+ ___
492
+
493
+ ### [InputSetComparison]
494
+
495
+ ▸ **[InputSetComparison]**(): (`state`: `number`, `newState`: `number`) => `boolean`
496
+
497
+ #### Returns
498
+
499
+ `fn`
500
+
501
+ ▸ (`state`, `newState`): `boolean`
502
+
503
+ ##### Parameters
504
+
505
+ | Name | Type |
506
+ | :------ | :------ |
507
+ | `state` | `number` |
508
+ | `newState` | `number` |
509
+
510
+ ##### Returns
511
+
512
+ `boolean`
513
+
514
+ #### Inherited from
515
+
516
+ [Input](../wiki/Input).[[InputSetComparison]](../wiki/Input#%5Binputsetcomparison%5D)
517
+
518
+ #### Defined in
519
+
520
+ [src/input.ts:195](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L195)
521
+
522
+ ___
523
+
524
+ ### [InputSet]
525
+
526
+ ▸ **[InputSet]**(`state`): `void`
527
+
528
+ Update the input's state and trigger all necessary callbacks.
529
+
530
+ #### Parameters
531
+
532
+ | Name | Type |
533
+ | :------ | :------ |
534
+ | `state` | `number` |
535
+
536
+ #### Returns
537
+
538
+ `void`
539
+
540
+ #### Inherited from
541
+
542
+ [Input](../wiki/Input).[[InputSet]](../wiki/Input#%5Binputset%5D)
543
+
544
+ #### Defined in
545
+
546
+ [src/input.ts:211](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L211)
547
+
548
+ ___
549
+
550
+ ### [asyncIterator]
551
+
552
+ ▸ **[asyncIterator]**(): `AsyncIterator`<[`Trigger`](../wiki/Trigger), `any`, `undefined`\>
553
+
554
+ #### Returns
555
+
556
+ `AsyncIterator`<[`Trigger`](../wiki/Trigger), `any`, `undefined`\>
557
+
558
+ #### Inherited from
559
+
560
+ [Input](../wiki/Input).[[asyncIterator]](../wiki/Input#%5Basynciterator%5D)
561
+
562
+ #### Defined in
563
+
564
+ [src/input.ts:135](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L135)
565
+
566
+ ___
567
+
568
+ ### [custom]
569
+
570
+ ▸ **[custom]**(): `string`
571
+
572
+ #### Returns
573
+
574
+ `string`
575
+
576
+ #### Inherited from
577
+
578
+ [Input](../wiki/Input).[[custom]](../wiki/Input#%5Bcustom%5D)
579
+
580
+ #### Defined in
581
+
582
+ [src/input.ts:127](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L127)
583
+
584
+ ___
585
+
586
+ ### [toPrimitive]
587
+
588
+ ▸ **[toPrimitive]**(`hint`): `string` \| `number`
589
+
590
+ #### Parameters
591
+
592
+ | Name | Type |
593
+ | :------ | :------ |
594
+ | `hint` | ``"string"`` \| ``"number"`` \| ``"default"`` |
595
+
596
+ #### Returns
597
+
598
+ `string` \| `number`
599
+
600
+ #### Inherited from
601
+
602
+ [Input](../wiki/Input).[[toPrimitive]](../wiki/Input#%5Btoprimitive%5D)
603
+
604
+ #### Defined in
605
+
606
+ [src/input.ts:139](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L139)
607
+
608
+ ___
609
+
610
+ ### addListener
611
+
612
+ ▸ **addListener**(`eventName`, `listener`): [`Trigger`](../wiki/Trigger)
613
+
614
+ Alias for `emitter.on(eventName, listener)`.
615
+
616
+ **`since`** v0.1.26
617
+
618
+ #### Parameters
619
+
620
+ | Name | Type |
621
+ | :------ | :------ |
622
+ | `eventName` | `string` \| `symbol` |
623
+ | `listener` | (...`args`: `any`[]) => `void` |
624
+
625
+ #### Returns
626
+
627
+ [`Trigger`](../wiki/Trigger)
628
+
629
+ #### Inherited from
630
+
631
+ [Input](../wiki/Input).[addListener](../wiki/Input#addlistener)
632
+
633
+ #### Defined in
634
+
635
+ node_modules/@types/node/events.d.ts:327
636
+
637
+ ___
638
+
639
+ ### changes
640
+
641
+ ▸ **changes**(`state`): `boolean`
642
+
643
+ #### Parameters
644
+
645
+ | Name | Type |
646
+ | :------ | :------ |
647
+ | `state` | `number` |
648
+
649
+ #### Returns
650
+
651
+ `boolean`
652
+
653
+ #### Defined in
654
+
655
+ [src/elements/trigger.ts:23](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/elements/trigger.ts#L23)
656
+
657
+ ___
658
+
659
+ ### emit
660
+
661
+ ▸ **emit**(`event`, ...`args`): `boolean`
662
+
663
+ #### Parameters
664
+
665
+ | Name | Type |
666
+ | :------ | :------ |
667
+ | `event` | [`InputEvent`](../wiki/Exports#inputevent) |
668
+ | `...args` | [[`Input`](../wiki/Input)<`number`\>, [`Input`](../wiki/Input)<`unknown`\> \| [`Input`](../wiki/Input)<`number`\>] |
669
+
670
+ #### Returns
671
+
672
+ `boolean`
673
+
674
+ #### Inherited from
675
+
676
+ [Input](../wiki/Input).[emit](../wiki/Input#emit)
677
+
678
+ #### Defined in
679
+
680
+ [src/input.ts:44](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L44)
681
+
682
+ ___
683
+
684
+ ### eventNames
685
+
686
+ ▸ **eventNames**(): (`string` \| `symbol`)[]
687
+
688
+ Returns an array listing the events for which the emitter has registered
689
+ listeners. The values in the array are strings or `Symbol`s.
690
+
691
+ ```js
692
+ const EventEmitter = require('events');
693
+ const myEE = new EventEmitter();
694
+ myEE.on('foo', () => {});
695
+ myEE.on('bar', () => {});
696
+
697
+ const sym = Symbol('symbol');
698
+ myEE.on(sym, () => {});
699
+
700
+ console.log(myEE.eventNames());
701
+ // Prints: [ 'foo', 'bar', Symbol(symbol) ]
702
+ ```
703
+
704
+ **`since`** v6.0.0
705
+
706
+ #### Returns
707
+
708
+ (`string` \| `symbol`)[]
709
+
710
+ #### Inherited from
711
+
712
+ [Input](../wiki/Input).[eventNames](../wiki/Input#eventnames)
713
+
714
+ #### Defined in
715
+
716
+ node_modules/@types/node/events.d.ts:642
717
+
718
+ ___
719
+
720
+ ### getMaxListeners
721
+
722
+ ▸ **getMaxListeners**(): `number`
723
+
724
+ Returns the current max listener value for the `EventEmitter` which is either
725
+ set by `emitter.setMaxListeners(n)` or defaults to [defaultMaxListeners](../wiki/Trigger#defaultmaxlisteners).
726
+
727
+ **`since`** v1.0.0
728
+
729
+ #### Returns
730
+
731
+ `number`
732
+
733
+ #### Inherited from
734
+
735
+ [Input](../wiki/Input).[getMaxListeners](../wiki/Input#getmaxlisteners)
736
+
737
+ #### Defined in
738
+
739
+ node_modules/@types/node/events.d.ts:499
740
+
741
+ ___
742
+
743
+ ### listenerCount
744
+
745
+ ▸ **listenerCount**(`eventName`): `number`
746
+
747
+ Returns the number of listeners listening to the event named `eventName`.
748
+
749
+ **`since`** v3.2.0
750
+
751
+ #### Parameters
752
+
753
+ | Name | Type | Description |
754
+ | :------ | :------ | :------ |
755
+ | `eventName` | `string` \| `symbol` | The name of the event being listened for |
756
+
757
+ #### Returns
758
+
759
+ `number`
760
+
761
+ #### Inherited from
762
+
763
+ [Input](../wiki/Input).[listenerCount](../wiki/Input#listenercount)
764
+
765
+ #### Defined in
766
+
767
+ node_modules/@types/node/events.d.ts:589
768
+
769
+ ___
770
+
771
+ ### listeners
772
+
773
+ ▸ **listeners**(`eventName`): `Function`[]
774
+
775
+ Returns a copy of the array of listeners for the event named `eventName`.
776
+
777
+ ```js
778
+ server.on('connection', (stream) => {
779
+ console.log('someone connected!');
780
+ });
781
+ console.log(util.inspect(server.listeners('connection')));
782
+ // Prints: [ [Function] ]
783
+ ```
784
+
785
+ **`since`** v0.1.26
786
+
787
+ #### Parameters
788
+
789
+ | Name | Type |
790
+ | :------ | :------ |
791
+ | `eventName` | `string` \| `symbol` |
792
+
793
+ #### Returns
794
+
795
+ `Function`[]
796
+
797
+ #### Inherited from
798
+
799
+ [Input](../wiki/Input).[listeners](../wiki/Input#listeners)
800
+
801
+ #### Defined in
802
+
803
+ node_modules/@types/node/events.d.ts:512
804
+
805
+ ___
806
+
807
+ ### next
808
+
809
+ ▸ **next**(): `Promise`<`IteratorResult`<[`Trigger`](../wiki/Trigger), `any`\>\>
810
+
811
+ Resolves on the next change to this input's state.
812
+
813
+ #### Returns
814
+
815
+ `Promise`<`IteratorResult`<[`Trigger`](../wiki/Trigger), `any`\>\>
816
+
817
+ #### Inherited from
818
+
819
+ [Input](../wiki/Input).[next](../wiki/Input#next)
820
+
821
+ #### Defined in
822
+
823
+ [src/input.ts:78](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L78)
824
+
825
+ ___
826
+
827
+ ### off
828
+
829
+ ▸ **off**(`eventName`, `listener`): [`Trigger`](../wiki/Trigger)
830
+
831
+ Alias for `emitter.removeListener()`.
832
+
833
+ **`since`** v10.0.0
834
+
835
+ #### Parameters
836
+
837
+ | Name | Type |
838
+ | :------ | :------ |
839
+ | `eventName` | `string` \| `symbol` |
840
+ | `listener` | (...`args`: `any`[]) => `void` |
841
+
842
+ #### Returns
843
+
844
+ [`Trigger`](../wiki/Trigger)
845
+
846
+ #### Inherited from
847
+
848
+ [Input](../wiki/Input).[off](../wiki/Input#off)
849
+
850
+ #### Defined in
851
+
852
+ node_modules/@types/node/events.d.ts:472
853
+
854
+ ___
855
+
856
+ ### on
857
+
858
+ ▸ **on**(`event`, `listener`): [`Trigger`](../wiki/Trigger)
859
+
860
+ #### Parameters
861
+
862
+ | Name | Type |
863
+ | :------ | :------ |
864
+ | `event` | [`InputEvent`](../wiki/Exports#inputevent) |
865
+ | `listener` | (`input`: [`Input`](../wiki/Input)<`number`\>, `changed`: [`Input`](../wiki/Input)<`unknown`\>) => `unknown` |
866
+
867
+ #### Returns
868
+
869
+ [`Trigger`](../wiki/Trigger)
870
+
871
+ #### Inherited from
872
+
873
+ [Input](../wiki/Input).[on](../wiki/Input#on)
874
+
875
+ #### Defined in
876
+
877
+ [src/input.ts:37](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L37)
878
+
879
+ ___
880
+
881
+ ### once
882
+
883
+ ▸ **once**(`eventName`, `listener`): [`Trigger`](../wiki/Trigger)
884
+
885
+ Adds a **one-time**`listener` function for the event named `eventName`. The
886
+ next time `eventName` is triggered, this listener is removed and then invoked.
887
+
888
+ ```js
889
+ server.once('connection', (stream) => {
890
+ console.log('Ah, we have our first user!');
891
+ });
892
+ ```
893
+
894
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
895
+
896
+ 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
897
+ event listener to the beginning of the listeners array.
898
+
899
+ ```js
900
+ const myEE = new EventEmitter();
901
+ myEE.once('foo', () => console.log('a'));
902
+ myEE.prependOnceListener('foo', () => console.log('b'));
903
+ myEE.emit('foo');
904
+ // Prints:
905
+ // b
906
+ // a
907
+ ```
908
+
909
+ **`since`** v0.3.0
910
+
911
+ #### Parameters
912
+
913
+ | Name | Type | Description |
914
+ | :------ | :------ | :------ |
915
+ | `eventName` | `string` \| `symbol` | The name of the event. |
916
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
917
+
918
+ #### Returns
919
+
920
+ [`Trigger`](../wiki/Trigger)
921
+
922
+ #### Inherited from
923
+
924
+ [Input](../wiki/Input).[once](../wiki/Input#once)
925
+
926
+ #### Defined in
927
+
928
+ node_modules/@types/node/events.d.ts:387
929
+
930
+ ___
931
+
932
+ ### prependListener
933
+
934
+ ▸ **prependListener**(`eventName`, `listener`): [`Trigger`](../wiki/Trigger)
935
+
936
+ Adds the `listener` function to the _beginning_ of the listeners array for the
937
+ event named `eventName`. No checks are made to see if the `listener` has
938
+ already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
939
+ times.
940
+
941
+ ```js
942
+ server.prependListener('connection', (stream) => {
943
+ console.log('someone connected!');
944
+ });
945
+ ```
946
+
947
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
948
+
949
+ **`since`** v6.0.0
950
+
951
+ #### Parameters
952
+
953
+ | Name | Type | Description |
954
+ | :------ | :------ | :------ |
955
+ | `eventName` | `string` \| `symbol` | The name of the event. |
956
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
957
+
958
+ #### Returns
959
+
960
+ [`Trigger`](../wiki/Trigger)
961
+
962
+ #### Inherited from
963
+
964
+ [Input](../wiki/Input).[prependListener](../wiki/Input#prependlistener)
965
+
966
+ #### Defined in
967
+
968
+ node_modules/@types/node/events.d.ts:607
969
+
970
+ ___
971
+
972
+ ### prependOnceListener
973
+
974
+ ▸ **prependOnceListener**(`eventName`, `listener`): [`Trigger`](../wiki/Trigger)
975
+
976
+ 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
977
+ listener is removed, and then invoked.
978
+
979
+ ```js
980
+ server.prependOnceListener('connection', (stream) => {
981
+ console.log('Ah, we have our first user!');
982
+ });
983
+ ```
984
+
985
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
986
+
987
+ **`since`** v6.0.0
988
+
989
+ #### Parameters
990
+
991
+ | Name | Type | Description |
992
+ | :------ | :------ | :------ |
993
+ | `eventName` | `string` \| `symbol` | The name of the event. |
994
+ | `listener` | (...`args`: `any`[]) => `void` | The callback function |
995
+
996
+ #### Returns
997
+
998
+ [`Trigger`](../wiki/Trigger)
999
+
1000
+ #### Inherited from
1001
+
1002
+ [Input](../wiki/Input).[prependOnceListener](../wiki/Input#prependoncelistener)
1003
+
1004
+ #### Defined in
1005
+
1006
+ node_modules/@types/node/events.d.ts:623
1007
+
1008
+ ___
1009
+
1010
+ ### promise
1011
+
1012
+ ▸ **promise**(): `Promise`<[`Trigger`](../wiki/Trigger)\>
1013
+
1014
+ Resolves on the next change to this input's state.
1015
+
1016
+ #### Returns
1017
+
1018
+ `Promise`<[`Trigger`](../wiki/Trigger)\>
1019
+
1020
+ #### Inherited from
1021
+
1022
+ [Input](../wiki/Input).[promise](../wiki/Input#promise)
1023
+
1024
+ #### Defined in
1025
+
1026
+ [src/input.ts:89](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L89)
1027
+
1028
+ ___
1029
+
1030
+ ### rawListeners
1031
+
1032
+ ▸ **rawListeners**(`eventName`): `Function`[]
1033
+
1034
+ Returns a copy of the array of listeners for the event named `eventName`,
1035
+ including any wrappers (such as those created by `.once()`).
1036
+
1037
+ ```js
1038
+ const emitter = new EventEmitter();
1039
+ emitter.once('log', () => console.log('log once'));
1040
+
1041
+ // Returns a new Array with a function `onceWrapper` which has a property
1042
+ // `listener` which contains the original listener bound above
1043
+ const listeners = emitter.rawListeners('log');
1044
+ const logFnWrapper = listeners[0];
1045
+
1046
+ // Logs "log once" to the console and does not unbind the `once` event
1047
+ logFnWrapper.listener();
1048
+
1049
+ // Logs "log once" to the console and removes the listener
1050
+ logFnWrapper();
1051
+
1052
+ emitter.on('log', () => console.log('log persistently'));
1053
+ // Will return a new Array with a single function bound by `.on()` above
1054
+ const newListeners = emitter.rawListeners('log');
1055
+
1056
+ // Logs "log persistently" twice
1057
+ newListeners[0]();
1058
+ emitter.emit('log');
1059
+ ```
1060
+
1061
+ **`since`** v9.4.0
1062
+
1063
+ #### Parameters
1064
+
1065
+ | Name | Type |
1066
+ | :------ | :------ |
1067
+ | `eventName` | `string` \| `symbol` |
1068
+
1069
+ #### Returns
1070
+
1071
+ `Function`[]
1072
+
1073
+ #### Inherited from
1074
+
1075
+ [Input](../wiki/Input).[rawListeners](../wiki/Input#rawlisteners)
1076
+
1077
+ #### Defined in
1078
+
1079
+ node_modules/@types/node/events.d.ts:542
1080
+
1081
+ ___
1082
+
1083
+ ### removeAllListeners
1084
+
1085
+ ▸ **removeAllListeners**(`event?`): [`Trigger`](../wiki/Trigger)
1086
+
1087
+ Removes all listeners, or those of the specified `eventName`.
1088
+
1089
+ It is bad practice to remove listeners added elsewhere in the code,
1090
+ particularly when the `EventEmitter` instance was created by some other
1091
+ component or module (e.g. sockets or file streams).
1092
+
1093
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
1094
+
1095
+ **`since`** v0.1.26
1096
+
1097
+ #### Parameters
1098
+
1099
+ | Name | Type |
1100
+ | :------ | :------ |
1101
+ | `event?` | `string` \| `symbol` |
1102
+
1103
+ #### Returns
1104
+
1105
+ [`Trigger`](../wiki/Trigger)
1106
+
1107
+ #### Inherited from
1108
+
1109
+ [Input](../wiki/Input).[removeAllListeners](../wiki/Input#removealllisteners)
1110
+
1111
+ #### Defined in
1112
+
1113
+ node_modules/@types/node/events.d.ts:483
1114
+
1115
+ ___
1116
+
1117
+ ### removeListener
1118
+
1119
+ ▸ **removeListener**(`eventName`, `listener`): [`Trigger`](../wiki/Trigger)
1120
+
1121
+ Removes the specified `listener` from the listener array for the event named`eventName`.
1122
+
1123
+ ```js
1124
+ const callback = (stream) => {
1125
+ console.log('someone connected!');
1126
+ };
1127
+ server.on('connection', callback);
1128
+ // ...
1129
+ server.removeListener('connection', callback);
1130
+ ```
1131
+
1132
+ `removeListener()` will remove, at most, one instance of a listener from the
1133
+ listener array. If any single listener has been added multiple times to the
1134
+ listener array for the specified `eventName`, then `removeListener()` must be
1135
+ called multiple times to remove each instance.
1136
+
1137
+ Once an event is emitted, all listeners attached to it at the
1138
+ 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
1139
+ not remove them from`emit()` in progress. Subsequent events behave as expected.
1140
+
1141
+ ```js
1142
+ const myEmitter = new MyEmitter();
1143
+
1144
+ const callbackA = () => {
1145
+ console.log('A');
1146
+ myEmitter.removeListener('event', callbackB);
1147
+ };
1148
+
1149
+ const callbackB = () => {
1150
+ console.log('B');
1151
+ };
1152
+
1153
+ myEmitter.on('event', callbackA);
1154
+
1155
+ myEmitter.on('event', callbackB);
1156
+
1157
+ // callbackA removes listener callbackB but it will still be called.
1158
+ // Internal listener array at time of emit [callbackA, callbackB]
1159
+ myEmitter.emit('event');
1160
+ // Prints:
1161
+ // A
1162
+ // B
1163
+
1164
+ // callbackB is now removed.
1165
+ // Internal listener array [callbackA]
1166
+ myEmitter.emit('event');
1167
+ // Prints:
1168
+ // A
1169
+ ```
1170
+
1171
+ Because listeners are managed using an internal array, calling this will
1172
+ change the position indices of any listener registered _after_ the listener
1173
+ being removed. This will not impact the order in which listeners are called,
1174
+ but it means that any copies of the listener array as returned by
1175
+ the `emitter.listeners()` method will need to be recreated.
1176
+
1177
+ When a single function has been added as a handler multiple times for a single
1178
+ event (as in the example below), `removeListener()` will remove the most
1179
+ recently added instance. In the example the `once('ping')`listener is removed:
1180
+
1181
+ ```js
1182
+ const ee = new EventEmitter();
1183
+
1184
+ function pong() {
1185
+ console.log('pong');
1186
+ }
1187
+
1188
+ ee.on('ping', pong);
1189
+ ee.once('ping', pong);
1190
+ ee.removeListener('ping', pong);
1191
+
1192
+ ee.emit('ping');
1193
+ ee.emit('ping');
1194
+ ```
1195
+
1196
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
1197
+
1198
+ **`since`** v0.1.26
1199
+
1200
+ #### Parameters
1201
+
1202
+ | Name | Type |
1203
+ | :------ | :------ |
1204
+ | `eventName` | `string` \| `symbol` |
1205
+ | `listener` | (...`args`: `any`[]) => `void` |
1206
+
1207
+ #### Returns
1208
+
1209
+ [`Trigger`](../wiki/Trigger)
1210
+
1211
+ #### Inherited from
1212
+
1213
+ [Input](../wiki/Input).[removeListener](../wiki/Input#removelistener)
1214
+
1215
+ #### Defined in
1216
+
1217
+ node_modules/@types/node/events.d.ts:467
1218
+
1219
+ ___
1220
+
1221
+ ### setMaxListeners
1222
+
1223
+ ▸ **setMaxListeners**(`n`): [`Trigger`](../wiki/Trigger)
1224
+
1225
+ By default `EventEmitter`s will print a warning if more than `10` listeners are
1226
+ added for a particular event. This is a useful default that helps finding
1227
+ memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
1228
+ modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
1229
+
1230
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
1231
+
1232
+ **`since`** v0.3.5
1233
+
1234
+ #### Parameters
1235
+
1236
+ | Name | Type |
1237
+ | :------ | :------ |
1238
+ | `n` | `number` |
1239
+
1240
+ #### Returns
1241
+
1242
+ [`Trigger`](../wiki/Trigger)
1243
+
1244
+ #### Inherited from
1245
+
1246
+ [Input](../wiki/Input).[setMaxListeners](../wiki/Input#setmaxlisteners)
1247
+
1248
+ #### Defined in
1249
+
1250
+ node_modules/@types/node/events.d.ts:493
1251
+
1252
+ ___
1253
+
1254
+ ### toString
1255
+
1256
+ ▸ **toString**(): `string`
1257
+
1258
+ Render a convenient debugging string.
1259
+
1260
+ #### Returns
1261
+
1262
+ `string`
1263
+
1264
+ #### Inherited from
1265
+
1266
+ [Input](../wiki/Input).[toString](../wiki/Input#tostring)
1267
+
1268
+ #### Defined in
1269
+
1270
+ [src/input.ts:98](https://github.com/nsfm/dualsense-ts/blob/6dc1604/src/input.ts#L98)
1271
+
1272
+ ___
1273
+
1274
+ ### getEventListeners
1275
+
1276
+ ▸ `Static` **getEventListeners**(`emitter`, `name`): `Function`[]
1277
+
1278
+ Returns a copy of the array of listeners for the event named `eventName`.
1279
+
1280
+ For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
1281
+ the emitter.
1282
+
1283
+ For `EventTarget`s this is the only way to get the event listeners for the
1284
+ event target. This is useful for debugging and diagnostic purposes.
1285
+
1286
+ ```js
1287
+ const { getEventListeners, EventEmitter } = require('events');
1288
+
1289
+ {
1290
+ const ee = new EventEmitter();
1291
+ const listener = () => console.log('Events are fun');
1292
+ ee.on('foo', listener);
1293
+ getEventListeners(ee, 'foo'); // [listener]
1294
+ }
1295
+ {
1296
+ const et = new EventTarget();
1297
+ const listener = () => console.log('Events are fun');
1298
+ et.addEventListener('foo', listener);
1299
+ getEventListeners(et, 'foo'); // [listener]
1300
+ }
1301
+ ```
1302
+
1303
+ **`since`** v15.2.0, v14.17.0
1304
+
1305
+ #### Parameters
1306
+
1307
+ | Name | Type |
1308
+ | :------ | :------ |
1309
+ | `emitter` | `EventEmitter` \| `DOMEventTarget` |
1310
+ | `name` | `string` \| `symbol` |
1311
+
1312
+ #### Returns
1313
+
1314
+ `Function`[]
1315
+
1316
+ #### Inherited from
1317
+
1318
+ [Input](../wiki/Input).[getEventListeners](../wiki/Input#geteventlisteners)
1319
+
1320
+ #### Defined in
1321
+
1322
+ node_modules/@types/node/events.d.ts:270
1323
+
1324
+ ___
1325
+
1326
+ ### listenerCount
1327
+
1328
+ ▸ `Static` **listenerCount**(`emitter`, `eventName`): `number`
1329
+
1330
+ A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
1331
+
1332
+ ```js
1333
+ const { EventEmitter, listenerCount } = require('events');
1334
+ const myEmitter = new EventEmitter();
1335
+ myEmitter.on('event', () => {});
1336
+ myEmitter.on('event', () => {});
1337
+ console.log(listenerCount(myEmitter, 'event'));
1338
+ // Prints: 2
1339
+ ```
1340
+
1341
+ **`since`** v0.9.12
1342
+
1343
+ **`deprecated`** Since v3.2.0 - Use `listenerCount` instead.
1344
+
1345
+ #### Parameters
1346
+
1347
+ | Name | Type | Description |
1348
+ | :------ | :------ | :------ |
1349
+ | `emitter` | `EventEmitter` | The emitter to query |
1350
+ | `eventName` | `string` \| `symbol` | The event name |
1351
+
1352
+ #### Returns
1353
+
1354
+ `number`
1355
+
1356
+ #### Inherited from
1357
+
1358
+ [Input](../wiki/Input).[listenerCount](../wiki/Input#listenercount-1)
1359
+
1360
+ #### Defined in
1361
+
1362
+ node_modules/@types/node/events.d.ts:242
1363
+
1364
+ ___
1365
+
1366
+ ### on
1367
+
1368
+ ▸ `Static` **on**(`emitter`, `eventName`, `options?`): `AsyncIterableIterator`<`any`\>
1369
+
1370
+ ```js
1371
+ const { on, EventEmitter } = require('events');
1372
+
1373
+ (async () => {
1374
+ const ee = new EventEmitter();
1375
+
1376
+ // Emit later on
1377
+ process.nextTick(() => {
1378
+ ee.emit('foo', 'bar');
1379
+ ee.emit('foo', 42);
1380
+ });
1381
+
1382
+ for await (const event of on(ee, 'foo')) {
1383
+ // The execution of this inner block is synchronous and it
1384
+ // processes one event at a time (even with await). Do not use
1385
+ // if concurrent execution is required.
1386
+ console.log(event); // prints ['bar'] [42]
1387
+ }
1388
+ // Unreachable here
1389
+ })();
1390
+ ```
1391
+
1392
+ Returns an `AsyncIterator` that iterates `eventName` events. It will throw
1393
+ if the `EventEmitter` emits `'error'`. It removes all listeners when
1394
+ exiting the loop. The `value` returned by each iteration is an array
1395
+ composed of the emitted event arguments.
1396
+
1397
+ An `AbortSignal` can be used to cancel waiting on events:
1398
+
1399
+ ```js
1400
+ const { on, EventEmitter } = require('events');
1401
+ const ac = new AbortController();
1402
+
1403
+ (async () => {
1404
+ const ee = new EventEmitter();
1405
+
1406
+ // Emit later on
1407
+ process.nextTick(() => {
1408
+ ee.emit('foo', 'bar');
1409
+ ee.emit('foo', 42);
1410
+ });
1411
+
1412
+ for await (const event of on(ee, 'foo', { signal: ac.signal })) {
1413
+ // The execution of this inner block is synchronous and it
1414
+ // processes one event at a time (even with await). Do not use
1415
+ // if concurrent execution is required.
1416
+ console.log(event); // prints ['bar'] [42]
1417
+ }
1418
+ // Unreachable here
1419
+ })();
1420
+
1421
+ process.nextTick(() => ac.abort());
1422
+ ```
1423
+
1424
+ **`since`** v13.6.0, v12.16.0
1425
+
1426
+ #### Parameters
1427
+
1428
+ | Name | Type | Description |
1429
+ | :------ | :------ | :------ |
1430
+ | `emitter` | `EventEmitter` | - |
1431
+ | `eventName` | `string` | The name of the event being listened for |
1432
+ | `options?` | `StaticEventEmitterOptions` | - |
1433
+
1434
+ #### Returns
1435
+
1436
+ `AsyncIterableIterator`<`any`\>
1437
+
1438
+ that iterates `eventName` events emitted by the `emitter`
1439
+
1440
+ #### Inherited from
1441
+
1442
+ [Input](../wiki/Input).[on](../wiki/Input#on-1)
1443
+
1444
+ #### Defined in
1445
+
1446
+ node_modules/@types/node/events.d.ts:221
1447
+
1448
+ ___
1449
+
1450
+ ### once
1451
+
1452
+ ▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
1453
+
1454
+ Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
1455
+ event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
1456
+ The `Promise` will resolve with an array of all the arguments emitted to the
1457
+ given event.
1458
+
1459
+ 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
1460
+ semantics and does not listen to the `'error'` event.
1461
+
1462
+ ```js
1463
+ const { once, EventEmitter } = require('events');
1464
+
1465
+ async function run() {
1466
+ const ee = new EventEmitter();
1467
+
1468
+ process.nextTick(() => {
1469
+ ee.emit('myevent', 42);
1470
+ });
1471
+
1472
+ const [value] = await once(ee, 'myevent');
1473
+ console.log(value);
1474
+
1475
+ const err = new Error('kaboom');
1476
+ process.nextTick(() => {
1477
+ ee.emit('error', err);
1478
+ });
1479
+
1480
+ try {
1481
+ await once(ee, 'myevent');
1482
+ } catch (err) {
1483
+ console.log('error happened', err);
1484
+ }
1485
+ }
1486
+
1487
+ run();
1488
+ ```
1489
+
1490
+ 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
1491
+ '`error'` event itself, then it is treated as any other kind of event without
1492
+ special handling:
1493
+
1494
+ ```js
1495
+ const { EventEmitter, once } = require('events');
1496
+
1497
+ const ee = new EventEmitter();
1498
+
1499
+ once(ee, 'error')
1500
+ .then(([err]) => console.log('ok', err.message))
1501
+ .catch((err) => console.log('error', err.message));
1502
+
1503
+ ee.emit('error', new Error('boom'));
1504
+
1505
+ // Prints: ok boom
1506
+ ```
1507
+
1508
+ An `AbortSignal` can be used to cancel waiting for the event:
1509
+
1510
+ ```js
1511
+ const { EventEmitter, once } = require('events');
1512
+
1513
+ const ee = new EventEmitter();
1514
+ const ac = new AbortController();
1515
+
1516
+ async function foo(emitter, event, signal) {
1517
+ try {
1518
+ await once(emitter, event, { signal });
1519
+ console.log('event emitted!');
1520
+ } catch (error) {
1521
+ if (error.name === 'AbortError') {
1522
+ console.error('Waiting for the event was canceled!');
1523
+ } else {
1524
+ console.error('There was an error', error.message);
1525
+ }
1526
+ }
1527
+ }
1528
+
1529
+ foo(ee, 'foo', ac.signal);
1530
+ ac.abort(); // Abort waiting for the event
1531
+ ee.emit('foo'); // Prints: Waiting for the event was canceled!
1532
+ ```
1533
+
1534
+ **`since`** v11.13.0, v10.16.0
1535
+
1536
+ #### Parameters
1537
+
1538
+ | Name | Type |
1539
+ | :------ | :------ |
1540
+ | `emitter` | `NodeEventTarget` |
1541
+ | `eventName` | `string` \| `symbol` |
1542
+ | `options?` | `StaticEventEmitterOptions` |
1543
+
1544
+ #### Returns
1545
+
1546
+ `Promise`<`any`[]\>
1547
+
1548
+ #### Inherited from
1549
+
1550
+ [Input](../wiki/Input).[once](../wiki/Input#once-1)
1551
+
1552
+ #### Defined in
1553
+
1554
+ node_modules/@types/node/events.d.ts:157
1555
+
1556
+ ▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
1557
+
1558
+ #### Parameters
1559
+
1560
+ | Name | Type |
1561
+ | :------ | :------ |
1562
+ | `emitter` | `DOMEventTarget` |
1563
+ | `eventName` | `string` |
1564
+ | `options?` | `StaticEventEmitterOptions` |
1565
+
1566
+ #### Returns
1567
+
1568
+ `Promise`<`any`[]\>
1569
+
1570
+ #### Inherited from
1571
+
1572
+ [Input](../wiki/Input).[once](../wiki/Input#once-1)
1573
+
1574
+ #### Defined in
1575
+
1576
+ node_modules/@types/node/events.d.ts:162
1577
+
1578
+ ___
1579
+
1580
+ ### setMaxListeners
1581
+
1582
+ ▸ `Static` **setMaxListeners**(`n?`, ...`eventTargets`): `void`
1583
+
1584
+ By default `EventEmitter`s will print a warning if more than `10` listeners are
1585
+ added for a particular event. This is a useful default that helps finding
1586
+ memory leaks. The `EventEmitter.setMaxListeners()` method allows the default limit to be
1587
+ modified (if eventTargets is empty) or modify the limit specified in every `EventTarget` | `EventEmitter` passed as arguments.
1588
+ The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
1589
+
1590
+ ```js
1591
+ EventEmitter.setMaxListeners(20);
1592
+ // Equivalent to
1593
+ EventEmitter.defaultMaxListeners = 20;
1594
+
1595
+ const eventTarget = new EventTarget();
1596
+ // Only way to increase limit for `EventTarget` instances
1597
+ // as these doesn't expose its own `setMaxListeners` method
1598
+ EventEmitter.setMaxListeners(20, eventTarget);
1599
+ ```
1600
+
1601
+ **`since`** v15.3.0, v14.17.0
1602
+
1603
+ #### Parameters
1604
+
1605
+ | Name | Type |
1606
+ | :------ | :------ |
1607
+ | `n?` | `number` |
1608
+ | `...eventTargets` | (`EventEmitter` \| `DOMEventTarget`)[] |
1609
+
1610
+ #### Returns
1611
+
1612
+ `void`
1613
+
1614
+ #### Inherited from
1615
+
1616
+ [Input](../wiki/Input).[setMaxListeners](../wiki/Input#setmaxlisteners-1)
1617
+
1618
+ #### Defined in
1619
+
1620
+ node_modules/@types/node/events.d.ts:290