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