-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdebounce-fn.node.txt
22 lines (18 loc) · 1.41 KB
/
debounce-fn.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
┏━━━━━━━━━━━━━━━━━┓
┃ DEBOUNCE-FN ┃
┗━━━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - p-debounce: for async FUNCs
# - debounce-fn: for sync FUNCs
VERSION ==> #6.0.0
DEBOUNCE-FN(FUNC(...)[, OPTS]) #Delay sync FUNC calls by OPTS.wait NUMms (def: 0)
->FUNC # - additional calls within that time cancels the previous call and resets the delay
# - even if arguments differ
# - all calls return undefined
#If OPTS.before true (def: false):
# - first call is not delayed, but additional calls are
# - additional calls still reset the delay
# - first call returns its value, additional calls return most recently returned one
# - if OPTS.after false (def: true), additional calls are ignored, except for resetting the delay
#OPTS:
# - maxWait NUM2 (def: Infinity): if wait longer, calls even if within NUMms debounce
FUNC.cancel() #