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