-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdot-prop.node.txt
35 lines (25 loc) · 1.47 KB
/
dot-prop.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
┏━━━━━━━━━━━━━━┓
┃ DOT-PROP ┃
┗━━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - dot-prop (preferred)
# - get-value
# - safe-get-prop
# - object-path: not maintained
VERSION ==> #9.0.0
VARR #Can contain:
# - .VAR (can be \-escaped)
# - [NUM]
#Can \-escape . [ ]
#Cannot be __proto__|prototype|constructor
getProperty(OBJ, 'VARR'[, VAL2]) #Retrieve OBJ[VARR]
->VAL #VAL2 is default value
#If OBJ primitive type, returns it instead.
setProperty(OBJ, 'VARR', VAL)->OBJ#Sets OBJ[VARR]
#Mutates.
#If OBJ primitive type, noop.
deleteProperty(OBJ, 'VARR')->BOOL #Delete OBJ[VARR]
#Mutates.
#If OBJ primitive type, noop.
hasProperty(OBJ, 'VARR')->BOOL #
escapePath('VAR')->'VAR' #Prepend . [ ] with \ when meant as 'VAR' not 'VARR'
deepKeys(OBJ)->'VARR'_ARR #Returns all possible 'VARR' that are not OBJ|ARR