-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathp-event.node.txt
37 lines (29 loc) · 2.33 KB
/
p-event.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
┏━━━━━━━━━━━━━┓
┃ P-EVENT ┃
┗━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - require('events').once() (preferred if Node only)
# - p-event (preferred if needs features or if Node + Deno + browser):
# cancelation, more-than-once, multiple events, multiple arguments, filtering, timeout, iterable
VERSION ==> #6.0.1
EMITTER #EVENTTARGET (DOM) or EVENTLISTENER (Node)
pEventMultiple #Resolves PPROMISE after OPTS.count events among 'EVENT'[_ARR] have been sent.
(EMITTER, 'EVENT'[_ARR][, OPTS]) #Resolves with PAYLOAD_ARR, where PAYLOAD is according to OPTS.multiArgs BOOL:
->PPROMISE # - false (def): first argument only
# - true: all arguments
#Rejects with PAYLOAD on first OPTS.rejectionEvents 'EVENT'_ERR (def: ['error'])
OPTS.resolveImmediately #BOOL (def: false)
OPTS.filter #FUNC(PAYLOAD)->BOOL. Whether to ignore those events
OPTS.timeout #NUM. Rejects after NUMms, using P-EVENT.TimeoutError
OPTS.signal #ABORT_SIGNAL
PPROMISE #See p-cancelable doc
#PPROMISE.cancel() removes listeners. Automatically done on resolution|rejection
pEvent(EMITTER, 'EVENT'[_ARR] #Like multiple() except:
[, OPTS|FUNC])->PPROMISE # - OPTS.count 1, and resolves with PAYLOAD_ARR[0]
# - OPTS.resolveImmediately false
# - FUNC is OPTS.filter
pEventIterator(EMITTER, #Like multiple() but as PROMISE_ITERABLE for each event.
'EVENT'[_ARR][, OPTS|FUNC]) #OPTS:
->PROMISE_ITERABLE # - multiArgs|filter: same as above
# - limit NUM (def: Infinity): stop after NUM events
# - resolutionEvents 'EVENT'_ARR (def: []): ends iteration on those events
# - rejectionEvents 'EVENT'_ARR (def: ['error']): returns rejected PROMISE on those events