dualsense-ts 2.0.2 → 2.0.13

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