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