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