-
Notifications
You must be signed in to change notification settings - Fork 16
/
js-cookie.javascript.txt
35 lines (27 loc) · 2.38 KB
/
js-cookie.javascript.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
JS-COOKIE
ALTERNATIVES ==> # - jquery-cookie: use jQuery
# - cookie: used by Express
# - js-cookie (preferred with node)
# - deno cookie (preferred with deno)
VERSION ==> #3.0.5
Cookie.withAttributes(OPTS)
->Cookie #Set default OPTS
OPTS.attributes #Defaults OPTS. Readonly. Def to {}
Cookie.get()->{ VAR: 'VAL' } #
Cookie.get('VAR')->'VAL' #
Cookie.set('VAR', 'VAL'[, OPTS]) #OPTS:
# - domain STR
# - path STR
# - expires DATE|NUM (in days)
# - secure BOOL
# - sameSite 'strict|lax|none'
Cookie.remove('VAR'[, OPTS]) #Must specify OPTS.path|domain
Cookie.converter #CONVERTER, i.e. OBJ with write|read() called to encode|decode 'VAL'
Cookie.converter.write('VAL')
->'VAL' #Call encodeURIComponent() on =;
Cookie.converter.read('VAL')
->'VAL' #Call decodeURIComponent() on =;
Cookie.withConverter(CONVERTER)
->Cookie #Adds a Cookie.converter (does not remove the default one, done before (on both write|read))