dualsense-ts 2.0.2 → 2.0.3

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