query-string 7.1.3 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/readme.md CHANGED
@@ -31,15 +31,6 @@
31
31
  <sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
32
32
  </div>
33
33
  </a>
34
- <br>
35
- <a href="https://oss.capital">
36
- <div>
37
- <img src="https://sindresorhus.com/assets/thanks/oss-capital-logo-white-bg.svg" width="300" alt="OSS Capital">
38
- </div>
39
- <div>
40
- <sup><b>Founded in 2018, OSS Capital is the first and only venture capital platform focused<br>exclusively on supporting early-stage COSS (commercial open source) startup founders.</b></sup>
41
- </div>
42
- </a>
43
34
  </p>
44
35
  </div>
45
36
 
@@ -49,18 +40,18 @@
49
40
 
50
41
  ## Install
51
42
 
52
- ```
53
- $ npm install query-string
43
+ ```sh
44
+ npm install query-string
54
45
  ```
55
46
 
56
47
  **Not `npm install querystring`!!!!!**
57
48
 
58
- This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari.
49
+ For browser usage, this package targets the latest version of Chrome, Firefox, and Safari.
59
50
 
60
51
  ## Usage
61
52
 
62
53
  ```js
63
- const queryString = require('query-string');
54
+ import queryString from 'query-string';
64
55
 
65
56
  console.log(location.search);
66
57
  //=> '?foo=bar'
@@ -115,7 +106,7 @@ Default: `'none'`
115
106
  - `'bracket'`: Parse arrays with bracket representation:
116
107
 
117
108
  ```js
118
- const queryString = require('query-string');
109
+ import queryString from 'query-string';
119
110
 
120
111
  queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
121
112
  //=> {foo: ['1', '2', '3']}
@@ -124,7 +115,7 @@ queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
124
115
  - `'index'`: Parse arrays with index representation:
125
116
 
126
117
  ```js
127
- const queryString = require('query-string');
118
+ import queryString from 'query-string';
128
119
 
129
120
  queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
130
121
  //=> {foo: ['1', '2', '3']}
@@ -133,7 +124,7 @@ queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
133
124
  - `'comma'`: Parse arrays with elements separated by comma:
134
125
 
135
126
  ```js
136
- const queryString = require('query-string');
127
+ import queryString from 'query-string';
137
128
 
138
129
  queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
139
130
  //=> {foo: ['1', '2', '3']}
@@ -142,7 +133,7 @@ queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
142
133
  - `'separator'`: Parse arrays with elements separated by a custom character:
143
134
 
144
135
  ```js
145
- const queryString = require('query-string');
136
+ import queryString from 'query-string';
146
137
 
147
138
  queryString.parse('foo=1|2|3', {arrayFormat: 'separator', arrayFormatSeparator: '|'});
148
139
  //=> {foo: ['1', '2', '3']}
@@ -151,7 +142,7 @@ queryString.parse('foo=1|2|3', {arrayFormat: 'separator', arrayFormatSeparator:
151
142
  - `'bracket-separator'`: Parse arrays (that are explicitly marked with brackets) with elements separated by a custom character:
152
143
 
153
144
  ```js
154
- const queryString = require('query-string');
145
+ import queryString from 'query-string';
155
146
 
156
147
  queryString.parse('foo[]', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
157
148
  //=> {foo: []}
@@ -175,7 +166,7 @@ queryString.parse('foo[]=1|2|3&bar=fluffy&baz[]=4', {arrayFormat: 'bracket-separ
175
166
  - `'colon-list-separator'`: Parse arrays with parameter names that are explicitly marked with `:list`:
176
167
 
177
168
  ```js
178
- const queryString = require('query-string');
169
+ import queryString from 'query-string';
179
170
 
180
171
  queryString.parse('foo:list=one&foo:list=two', {arrayFormat: 'colon-list-separator'});
181
172
  //=> {foo: ['one', 'two']}
@@ -184,7 +175,7 @@ queryString.parse('foo:list=one&foo:list=two', {arrayFormat: 'colon-list-separat
184
175
  - `'none'`: Parse arrays with elements using duplicate keys:
185
176
 
186
177
  ```js
187
- const queryString = require('query-string');
178
+ import queryString from 'query-string';
188
179
 
189
180
  queryString.parse('foo=1&foo=2&foo=3');
190
181
  //=> {foo: ['1', '2', '3']}
@@ -210,7 +201,7 @@ Type: `boolean`\
210
201
  Default: `false`
211
202
 
212
203
  ```js
213
- const queryString = require('query-string');
204
+ import queryString from 'query-string';
214
205
 
215
206
  queryString.parse('foo=1', {parseNumbers: true});
216
207
  //=> {foo: 1}
@@ -224,7 +215,7 @@ Type: `boolean`\
224
215
  Default: `false`
225
216
 
226
217
  ```js
227
- const queryString = require('query-string');
218
+ import queryString from 'query-string';
228
219
 
229
220
  queryString.parse('foo=true', {parseBooleans: true});
230
221
  //=> {foo: true}
@@ -262,7 +253,7 @@ Default: `'none'`
262
253
  - `'bracket'`: Serialize arrays using bracket representation:
263
254
 
264
255
  ```js
265
- const queryString = require('query-string');
256
+ import queryString from 'query-string';
266
257
 
267
258
  queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});
268
259
  //=> 'foo[]=1&foo[]=2&foo[]=3'
@@ -271,7 +262,7 @@ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});
271
262
  - `'index'`: Serialize arrays using index representation:
272
263
 
273
264
  ```js
274
- const queryString = require('query-string');
265
+ import queryString from 'query-string';
275
266
 
276
267
  queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
277
268
  //=> 'foo[0]=1&foo[1]=2&foo[2]=3'
@@ -280,7 +271,7 @@ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
280
271
  - `'comma'`: Serialize arrays by separating elements with comma:
281
272
 
282
273
  ```js
283
- const queryString = require('query-string');
274
+ import queryString from 'query-string';
284
275
 
285
276
  queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'comma'});
286
277
  //=> 'foo=1,2,3'
@@ -294,7 +285,7 @@ queryString.stringify({foo: [1, null, '']}, {arrayFormat: 'comma'});
294
285
  - `'separator'`: Serialize arrays by separating elements with a custom character:
295
286
 
296
287
  ```js
297
- const queryString = require('query-string');
288
+ import queryString from 'query-string';
298
289
 
299
290
  queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'separator', arrayFormatSeparator: '|'});
300
291
  //=> 'foo=1|2|3'
@@ -303,7 +294,7 @@ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'separator', arrayFormatSe
303
294
  - `'bracket-separator'`: Serialize arrays by explicitly post-fixing array names with brackets and separating elements with a custom character:
304
295
 
305
296
  ```js
306
- const queryString = require('query-string');
297
+ import queryString from 'query-string';
307
298
 
308
299
  queryString.stringify({foo: []}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
309
300
  //=> 'foo[]'
@@ -330,7 +321,7 @@ queryString.stringify({foo: [1, 2, 3], bar: 'fluffy', baz: [4]}, {arrayFormat: '
330
321
  - `'colon-list-separator'`: Serialize arrays with parameter names that are explicitly marked with `:list`:
331
322
 
332
323
  ```js
333
- const queryString = require('query-string');
324
+ import queryString from 'query-string';
334
325
 
335
326
  queryString.stringify({foo: ['one', 'two']}, {arrayFormat: 'colon-list-separator'});
336
327
  //=> 'foo:list=one&foo:list=two'
@@ -339,7 +330,7 @@ queryString.stringify({foo: ['one', 'two']}, {arrayFormat: 'colon-list-separator
339
330
  - `'none'`: Serialize arrays by using duplicate keys:
340
331
 
341
332
  ```js
342
- const queryString = require('query-string');
333
+ import queryString from 'query-string';
343
334
 
344
335
  queryString.stringify({foo: [1, 2, 3]});
345
336
  //=> 'foo=1&foo=2&foo=3'
@@ -359,7 +350,7 @@ Type: `Function | boolean`
359
350
  Supports both `Function` as a custom sorting function or `false` to disable sorting.
360
351
 
361
352
  ```js
362
- const queryString = require('query-string');
353
+ import queryString from 'query-string';
363
354
 
364
355
  const order = ['c', 'a', 'b'];
365
356
 
@@ -370,7 +361,7 @@ queryString.stringify({a: 1, b: 2, c: 3}, {
370
361
  ```
371
362
 
372
363
  ```js
373
- const queryString = require('query-string');
364
+ import queryString from 'query-string';
374
365
 
375
366
  queryString.stringify({b: 1, c: 2, a: 3}, {sort: false});
376
367
  //=> 'b=1&c=2&a=3'
@@ -388,7 +379,7 @@ Type: `boolean`\
388
379
  Default: `false`
389
380
 
390
381
  ```js
391
- const queryString = require('query-string');
382
+ import queryString from 'query-string';
392
383
 
393
384
  queryString.stringify({a: 1, b: undefined, c: null, d: 4}, {
394
385
  skipNull: true
@@ -397,7 +388,7 @@ queryString.stringify({a: 1, b: undefined, c: null, d: 4}, {
397
388
  ```
398
389
 
399
390
  ```js
400
- const queryString = require('query-string');
391
+ import queryString from 'query-string';
401
392
 
402
393
  queryString.stringify({a: undefined, b: null}, {
403
394
  skipNull: true
@@ -413,7 +404,7 @@ Type: `boolean`\
413
404
  Default: `false`
414
405
 
415
406
  ```js
416
- const queryString = require('query-string');
407
+ import queryString from 'query-string';
417
408
 
418
409
  queryString.stringify({a: 1, b: '', c: '', d: 4}, {
419
410
  skipEmptyString: true
@@ -422,7 +413,7 @@ queryString.stringify({a: 1, b: '', c: '', d: 4}, {
422
413
  ```
423
414
 
424
415
  ```js
425
- const queryString = require('query-string');
416
+ import queryString from 'query-string';
426
417
 
427
418
  queryString.stringify({a: '', b: ''}, {
428
419
  skipEmptyString: true
@@ -445,7 +436,7 @@ Returns an object with a `url` and `query` property.
445
436
  If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
446
437
 
447
438
  ```js
448
- const queryString = require('query-string');
439
+ import queryString from 'query-string';
449
440
 
450
441
  queryString.parseUrl('https://foo.bar?foo=bar');
451
442
  //=> {url: 'https://foo.bar', query: {foo: 'bar'}}
@@ -470,7 +461,7 @@ Type: `boolean`\
470
461
  Default: `false`
471
462
 
472
463
  ```js
473
- const queryString = require('query-string');
464
+ import queryString from 'query-string';
474
465
 
475
466
  queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
476
467
  //=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
@@ -529,7 +520,7 @@ Pick query parameters from a URL.
529
520
  Returns a string with the new URL.
530
521
 
531
522
  ```js
532
- const queryString = require('query-string');
523
+ import queryString from 'query-string';
533
524
 
534
525
  queryString.pick('https://foo.bar?foo=1&bar=2#hello', ['foo']);
535
526
  //=> 'https://foo.bar?foo=1#hello'
@@ -546,7 +537,7 @@ Exclude query parameters from a URL.
546
537
  Returns a string with the new URL.
547
538
 
548
539
  ```js
549
- const queryString = require('query-string');
540
+ import queryString from 'query-string';
550
541
 
551
542
  queryString.exclude('https://foo.bar?foo=1&bar=2#hello', ['foo']);
552
543
  //=> 'https://foo.bar?bar=2#hello'
@@ -586,7 +577,7 @@ This module intentionally doesn't support nesting as it's not spec'd and varies
586
577
  You're much better off just converting the object to a JSON string:
587
578
 
588
579
  ```js
589
- const queryString = require('query-string');
580
+ import queryString from 'query-string';
590
581
 
591
582
  queryString.stringify({
592
583
  foo: 'bar',
@@ -600,7 +591,7 @@ queryString.stringify({
600
591
  However, there is support for multiple instances of the same key:
601
592
 
602
593
  ```js
603
- const queryString = require('query-string');
594
+ import queryString from 'query-string';
604
595
 
605
596
  queryString.parse('likes=cake&name=bob&likes=icecream');
606
597
  //=> {likes: ['cake', 'icecream'], name: 'bob'}
@@ -614,7 +605,7 @@ queryString.stringify({color: ['taupe', 'chartreuse'], id: '515'});
614
605
  Sometimes you want to unset a key, or maybe just make it present without assigning a value to it. Here is how falsy values are stringified:
615
606
 
616
607
  ```js
617
- const queryString = require('query-string');
608
+ import queryString from 'query-string';
618
609
 
619
610
  queryString.stringify({foo: false});
620
611
  //=> 'foo=false'
@@ -631,9 +622,3 @@ queryString.stringify({foo: undefined});
631
622
  ### Why is it parsing `+` as a space?
632
623
 
633
624
  See [this answer](https://github.com/sindresorhus/query-string/issues/305).
634
-
635
- ## query-string for enterprise
636
-
637
- Available as part of the Tidelift Subscription.
638
-
639
- The maintainers of query-string and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-query-string?utm_source=npm-query-string&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)