dualsense-ts 2.0.0 → 2.0.3

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