-
Notifications
You must be signed in to change notification settings - Fork 16
/
qs.node.txt
73 lines (67 loc) · 6.54 KB
/
qs.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
┏━━━━━━━━┓
┃ QS ┃
┗━━━━━━━━┛
ALTERNATIVES ==> # - URLSearchParams: fewer features but standard and built-in
# - qs: more features, Node.js only
VERSION ==> #6.13.0
QUERY_OBJ #Can be:
# - QUERY_OBJ.VAR.VAR2 VAL <-> 'VAR[VAR2]=VAL'
# - can be nested: max depth is OPTS.[strict]depth BOOL|NUM (def: 5)
# - OPTS.strictDepth throws, OPTS.depth silently ignores
# - QUERY_OBJ.VAR.VAR2 VAL <- 'VAR.VAR2=VAL'
# - if OPTS.allowDots true
# - dots in VAR itself is encoded|decoded as %252E, if OPTS.encodeDotInKeys|decodeDotInKeys true
# - QUERY_OBJ.VAR ARR <-> 'VAR[]=VAL&VAR[]=VAL2'
# - stringify() only if OPTS.arrayFormat 'brackets'
# - QUERY_OBJ.VAR ARR <-> 'VAR[UINT]=VAL&VAR[UINT2]=VAL2'
# - max UINT size is OPTS.arrayLimit (def: 20):
# otherwise treated as an OBJ
# - parse() can be disabled with OPTS.parseArrays false
# - parse() remove undefined indexes unless OPTS.allowSparse true
# - stringify() only if OPTS.arrayFormat 'indices' (def)
# - QUERY_OBJ.VAR empty ARR <-> 'VAR[]'
# - if OPTS.allowEmptyArrays true
# - QUERY_OBJ.VAR ARR <-> 'VAR=VAL&VAR=VAL2':
# - stringify() only if OPTS.arrayFormat 'repeat' or OPTS.indices false
# - QUERY_OBJ.VAR ARR <-> 'VAR=VAL,VAL2,...'
# - parse() only if OPTS.comma true (def: false)
# - can be combined with the ones above
# - stringify() only if OPTS.arrayFormat 'comma'
# - if OPTS.commaRoundTrip true (def: false), make all values ARRs, so
# that parse() + stringify() is idempotent
#[ ] is and should be percent-encoded
# - since [ ] is invalid in URIs
QS.parse('QUERY'[, OPTS])->QUERY_OBJ #OPTS:
# - parameterLimit NUM: max number of variables
# - decoder(...) (def: decodeURIComponent()): custom escaping
# - charset 'utf-8' (def) or 'iso-8859-1' (for old IE): instead of the one specified in HTTP headers
# - charsetSentinel BOOL (def: false): if ut8=✓ present, guess OPTS.charset from ✓ encoding
# - interpretNumericEntities BOOL (def: false): decode HTML escapes &#NUM;
# - strictNullHandling: see below
# - ignoreQueryPrefix BOOL (def: false): ignore leading ?
# - plainObjects BOOL (def: false): make QUERY_OBJ not inherit from OBJ
# - duplicates STR: when same VAR multiple times:
# - 'combine' (def): turn into ARR
# - 'first|last': only use first|last VAL
# - depth, allowDots, parseArrays, allowSparse, allowEmptyArrays, comma: see above
# - allowPrototypes BOOL: if false (def), do not allow Object.prototype.VAR, e.g. 'hasOwnProperty'
QS.stringify(QUERY_OBJ[, OPTS])->'QUERY' #OPTS:
# - delimiter STR|REGEXP (def: "&")
# - encode false: do not escape VARs|VALs
# - encodeValuesOnly false: do not escape VARs
# - encoder(...) (def: encodeURIComponent()): custom escaping
# - charset 'utf-8' (def) or 'iso-8859-1'
# - 'iso-8859-1' also encode HTML escapes &#NUM;
# - charsetSentinel BOOL (def: false): adds ut8=✓
# - serializeDate(DATE)->'DATE'
# - addQueryPrefix BOOL (def: false): add leading ?
# - filter('VAR', VAL)->VAL
# - strictNullHandling BOOL:
# - if false (def), VAR: null|'' -> "VAR="
# - if true, VAR: '' -> "VAR=", VAR: null -> "VAR"
# - skipNulls BOOL:
# - if false (def), VAR: undefined -> skipped
# - if true, VAR: undefined|null -> skipped
# - format 'RFC3986' (def) or 'RFC1738':
# - main difference: ' ' -> + (in RFC1738) and -> %20 (in RFC3986)
# - allowDots, arrayFormat, allowEmptyArrays, indices, commaRoundTrip: see above