@common.js/query-string 8.1.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ # @common.js/query-string
2
+
3
+ The [query-string](https://www.npmjs.com/package/query-string) package exported as CommonJS modules.
4
+
5
+ Exported from [query-string@8.1.0](https://www.npmjs.com/package/query-string/v/8.1.0) using https://github.com/etienne-martin/common.js.
package/base.d.ts ADDED
@@ -0,0 +1,562 @@
1
+ export type ParseOptions = {
2
+ /**
3
+ Decode the keys and values. URI components are decoded with [`decode-uri-component`](https://github.com/SamVerschueren/decode-uri-component).
4
+
5
+ @default true
6
+ */
7
+ readonly decode?: boolean;
8
+
9
+ /**
10
+ @default 'none'
11
+
12
+ - `bracket`: Parse arrays with bracket representation:
13
+
14
+ ```
15
+ import queryString from 'query-string';
16
+
17
+ queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
18
+ //=> {foo: ['1', '2', '3']}
19
+ ```
20
+
21
+ - `index`: Parse arrays with index representation:
22
+
23
+ ```
24
+ import queryString from 'query-string';
25
+
26
+ queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
27
+ //=> {foo: ['1', '2', '3']}
28
+ ```
29
+
30
+ - `comma`: Parse arrays with elements separated by comma:
31
+
32
+ ```
33
+ import queryString from 'query-string';
34
+
35
+ queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
36
+ //=> {foo: ['1', '2', '3']}
37
+ ```
38
+
39
+ - `separator`: Parse arrays with elements separated by a custom character:
40
+
41
+ ```
42
+ import queryString from 'query-string';
43
+
44
+ queryString.parse('foo=1|2|3', {arrayFormat: 'separator', arrayFormatSeparator: '|'});
45
+ //=> {foo: ['1', '2', '3']}
46
+ ```
47
+
48
+ - `bracket-separator`: Parse arrays (that are explicitly marked with brackets) with elements separated by a custom character:
49
+
50
+ ```
51
+ import queryString from 'query-string';
52
+
53
+ queryString.parse('foo[]', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
54
+ //=> {foo: []}
55
+
56
+ queryString.parse('foo[]=', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
57
+ //=> {foo: ['']}
58
+
59
+ queryString.parse('foo[]=1', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
60
+ //=> {foo: ['1']}
61
+
62
+ queryString.parse('foo[]=1|2|3', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
63
+ //=> {foo: ['1', '2', '3']}
64
+
65
+ queryString.parse('foo[]=1||3|||6', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
66
+ //=> {foo: ['1', '', 3, '', '', '6']}
67
+
68
+ queryString.parse('foo[]=1|2|3&bar=fluffy&baz[]=4', {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
69
+ //=> {foo: ['1', '2', '3'], bar: 'fluffy', baz:['4']}
70
+ ```
71
+
72
+ - `colon-list-separator`: Parse arrays with parameter names that are explicitly marked with `:list`:
73
+
74
+ ```
75
+ import queryString from 'query-string';
76
+
77
+ queryString.parse('foo:list=one&foo:list=two', {arrayFormat: 'colon-list-separator'});
78
+ //=> {foo: ['one', 'two']}
79
+ ```
80
+
81
+ - `none`: Parse arrays with elements using duplicate keys:
82
+
83
+ ```
84
+ import queryString from 'query-string';
85
+
86
+ queryString.parse('foo=1&foo=2&foo=3');
87
+ //=> {foo: ['1', '2', '3']}
88
+ ```
89
+ */
90
+ readonly arrayFormat?: 'bracket' | 'index' | 'comma' | 'separator' | 'bracket-separator' | 'colon-list-separator' | 'none';
91
+
92
+ /**
93
+ The character used to separate array elements when using `{arrayFormat: 'separator'}`.
94
+
95
+ @default ,
96
+ */
97
+ readonly arrayFormatSeparator?: string;
98
+
99
+ /**
100
+ Supports both `Function` as a custom sorting function or `false` to disable sorting.
101
+
102
+ If omitted, keys are sorted using `Array#sort`, which means, converting them to strings and comparing strings in Unicode code point order.
103
+
104
+ @default true
105
+
106
+ @example
107
+ ```
108
+ import queryString from 'query-string';
109
+
110
+ const order = ['c', 'a', 'b'];
111
+
112
+ queryString.parse('?a=one&b=two&c=three', {
113
+ sort: (itemLeft, itemRight) => order.indexOf(itemLeft) - order.indexOf(itemRight)
114
+ });
115
+ //=> {c: 'three', a: 'one', b: 'two'}
116
+ ```
117
+
118
+ @example
119
+ ```
120
+ import queryString from 'query-string';
121
+
122
+ queryString.parse('?a=one&c=three&b=two', {sort: false});
123
+ //=> {a: 'one', c: 'three', b: 'two'}
124
+ ```
125
+ */
126
+ readonly sort?: ((itemLeft: string, itemRight: string) => number) | false;
127
+
128
+ /**
129
+ Parse the value as a number type instead of string type if it's a number.
130
+
131
+ @default false
132
+
133
+ @example
134
+ ```
135
+ import queryString from 'query-string';
136
+
137
+ queryString.parse('foo=1', {parseNumbers: true});
138
+ //=> {foo: 1}
139
+ ```
140
+ */
141
+ readonly parseNumbers?: boolean;
142
+
143
+ /**
144
+ Parse the value as a boolean type instead of string type if it's a boolean.
145
+
146
+ @default false
147
+
148
+ @example
149
+ ```
150
+ import queryString from 'query-string';
151
+
152
+ queryString.parse('foo=true', {parseBooleans: true});
153
+ //=> {foo: true}
154
+ ```
155
+ */
156
+ readonly parseBooleans?: boolean;
157
+
158
+ /**
159
+ Parse the fragment identifier from the URL and add it to result object.
160
+
161
+ @default false
162
+
163
+ @example
164
+ ```
165
+ import queryString from 'query-string';
166
+
167
+ queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
168
+ //=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
169
+ ```
170
+ */
171
+ readonly parseFragmentIdentifier?: boolean;
172
+ };
173
+
174
+ // eslint-disable-next-line @typescript-eslint/ban-types
175
+ export type ParsedQuery<T = string> = Record<string, T | null | Array<T | null>>;
176
+
177
+ /**
178
+ Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.
179
+
180
+ The returned object is created with [`Object.create(null)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create) and thus does not have a `prototype`.
181
+
182
+ @param query - The query string to parse.
183
+ */
184
+ export function parse(query: string, options: {parseBooleans: true; parseNumbers: true} & ParseOptions): ParsedQuery<string | boolean | number>;
185
+ export function parse(query: string, options: {parseBooleans: true} & ParseOptions): ParsedQuery<string | boolean>;
186
+ export function parse(query: string, options: {parseNumbers: true} & ParseOptions): ParsedQuery<string | number>;
187
+ export function parse(query: string, options?: ParseOptions): ParsedQuery;
188
+
189
+ export type ParsedUrl = {
190
+ readonly url: string;
191
+ readonly query: ParsedQuery;
192
+
193
+ /**
194
+ The fragment identifier of the URL.
195
+
196
+ Present when the `parseFragmentIdentifier` option is `true`.
197
+ */
198
+ readonly fragmentIdentifier?: string;
199
+ };
200
+
201
+ /**
202
+ Extract the URL and the query string as an object.
203
+
204
+ If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
205
+
206
+ @param url - The URL to parse.
207
+
208
+ @example
209
+ ```
210
+ import queryString from 'query-string';
211
+
212
+ queryString.parseUrl('https://foo.bar?foo=bar');
213
+ //=> {url: 'https://foo.bar', query: {foo: 'bar'}}
214
+
215
+ queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
216
+ //=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
217
+ ```
218
+ */
219
+ export function parseUrl(url: string, options?: ParseOptions): ParsedUrl;
220
+
221
+ export type StringifyOptions = {
222
+ /**
223
+ Strictly encode URI components with [`strict-uri-encode`](https://github.com/kevva/strict-uri-encode). It uses [`encodeURIComponent`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to `false`. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
224
+
225
+ @default true
226
+ */
227
+ readonly strict?: boolean;
228
+
229
+ /**
230
+ [URL encode](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) the keys and values.
231
+
232
+ @default true
233
+ */
234
+ readonly encode?: boolean;
235
+
236
+ /**
237
+ @default 'none'
238
+
239
+ - `bracket`: Serialize arrays using bracket representation:
240
+
241
+ ```
242
+ import queryString from 'query-string';
243
+
244
+ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});
245
+ //=> 'foo[]=1&foo[]=2&foo[]=3'
246
+ ```
247
+
248
+ - `index`: Serialize arrays using index representation:
249
+
250
+ ```
251
+ import queryString from 'query-string';
252
+
253
+ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
254
+ //=> 'foo[0]=1&foo[1]=2&foo[2]=3'
255
+ ```
256
+
257
+ - `comma`: Serialize arrays by separating elements with comma:
258
+
259
+ ```
260
+ import queryString from 'query-string';
261
+
262
+ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'comma'});
263
+ //=> 'foo=1,2,3'
264
+
265
+ queryString.stringify({foo: [1, null, '']}, {arrayFormat: 'comma'});
266
+ //=> 'foo=1,,'
267
+ // Note that typing information for null values is lost
268
+ // and `.parse('foo=1,,')` would return `{foo: [1, '', '']}`.
269
+ ```
270
+
271
+ - `separator`: Serialize arrays by separating elements with character:
272
+
273
+ ```
274
+ import queryString from 'query-string';
275
+
276
+ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'separator', arrayFormatSeparator: '|'});
277
+ //=> 'foo=1|2|3'
278
+ ```
279
+
280
+ - `bracket-separator`: Serialize arrays by explicitly post-fixing array names with brackets and separating elements with a custom character:
281
+
282
+ ```
283
+ import queryString from 'query-string';
284
+
285
+ queryString.stringify({foo: []}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
286
+ //=> 'foo[]'
287
+
288
+ queryString.stringify({foo: ['']}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
289
+ //=> 'foo[]='
290
+
291
+ queryString.stringify({foo: [1]}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
292
+ //=> 'foo[]=1'
293
+
294
+ queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
295
+ //=> 'foo[]=1|2|3'
296
+
297
+ queryString.stringify({foo: [1, '', 3, null, null, 6]}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
298
+ //=> 'foo[]=1||3|||6'
299
+
300
+ queryString.stringify({foo: [1, '', 3, null, null, 6]}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|', skipNull: true});
301
+ //=> 'foo[]=1||3|6'
302
+
303
+ queryString.stringify({foo: [1, 2, 3], bar: 'fluffy', baz: [4]}, {arrayFormat: 'bracket-separator', arrayFormatSeparator: '|'});
304
+ //=> 'foo[]=1|2|3&bar=fluffy&baz[]=4'
305
+ ```
306
+
307
+ - `colon-list-separator`: Serialize arrays with parameter names that are explicitly marked with `:list`:
308
+
309
+ ```js
310
+ import queryString from 'query-string';
311
+
312
+ queryString.stringify({foo: ['one', 'two']}, {arrayFormat: 'colon-list-separator'});
313
+ //=> 'foo:list=one&foo:list=two'
314
+ ```
315
+
316
+ - `none`: Serialize arrays by using duplicate keys:
317
+
318
+ ```
319
+ import queryString from 'query-string';
320
+
321
+ queryString.stringify({foo: [1, 2, 3]});
322
+ //=> 'foo=1&foo=2&foo=3'
323
+ ```
324
+ */
325
+ readonly arrayFormat?: 'bracket' | 'index' | 'comma' | 'separator' | 'bracket-separator' | 'colon-list-separator' | 'none';
326
+
327
+ /**
328
+ The character used to separate array elements when using `{arrayFormat: 'separator'}`.
329
+
330
+ @default ,
331
+ */
332
+ readonly arrayFormatSeparator?: string;
333
+
334
+ /**
335
+ Supports both `Function` as a custom sorting function or `false` to disable sorting.
336
+
337
+ If omitted, keys are sorted using `Array#sort`, which means, converting them to strings and comparing strings in Unicode code point order.
338
+
339
+ @default true
340
+
341
+ @example
342
+ ```
343
+ import queryString from 'query-string';
344
+
345
+ const order = ['c', 'a', 'b'];
346
+
347
+ queryString.stringify({a: 1, b: 2, c: 3}, {
348
+ sort: (itemLeft, itemRight) => order.indexOf(itemLeft) - order.indexOf(itemRight)
349
+ });
350
+ //=> 'c=3&a=1&b=2'
351
+ ```
352
+
353
+ @example
354
+ ```
355
+ import queryString from 'query-string';
356
+
357
+ queryString.stringify({b: 1, c: 2, a: 3}, {sort: false});
358
+ //=> 'b=1&c=2&a=3'
359
+ ```
360
+ */
361
+ readonly sort?: ((itemLeft: string, itemRight: string) => number) | false;
362
+
363
+ /**
364
+ Skip keys with `null` as the value.
365
+
366
+ Note that keys with `undefined` as the value are always skipped.
367
+
368
+ @default false
369
+
370
+ @example
371
+ ```
372
+ import queryString from 'query-string';
373
+
374
+ queryString.stringify({a: 1, b: undefined, c: null, d: 4}, {
375
+ skipNull: true
376
+ });
377
+ //=> 'a=1&d=4'
378
+
379
+ queryString.stringify({a: undefined, b: null}, {
380
+ skipNull: true
381
+ });
382
+ //=> ''
383
+ ```
384
+ */
385
+ readonly skipNull?: boolean;
386
+
387
+ /**
388
+ Skip keys with an empty string as the value.
389
+
390
+ @default false
391
+
392
+ @example
393
+ ```
394
+ import queryString from 'query-string';
395
+
396
+ queryString.stringify({a: 1, b: '', c: '', d: 4}, {
397
+ skipEmptyString: true
398
+ });
399
+ //=> 'a=1&d=4'
400
+ ```
401
+
402
+ @example
403
+ ```
404
+ import queryString from 'query-string';
405
+
406
+ queryString.stringify({a: '', b: ''}, {
407
+ skipEmptyString: true
408
+ });
409
+ //=> ''
410
+ ```
411
+ */
412
+ readonly skipEmptyString?: boolean;
413
+ };
414
+
415
+ export type Stringifiable = string | boolean | number | null | undefined; // eslint-disable-line @typescript-eslint/ban-types
416
+
417
+ export type StringifiableRecord = Record<
418
+ string,
419
+ Stringifiable | readonly Stringifiable[]
420
+ >;
421
+
422
+ /**
423
+ Stringify an object into a query string and sort the keys.
424
+ */
425
+ export function stringify(
426
+ // TODO: Use the below instead when the following TS issues are fixed:
427
+ // - https://github.com/microsoft/TypeScript/issues/15300
428
+ // - https://github.com/microsoft/TypeScript/issues/42021
429
+ // Context: https://github.com/sindresorhus/query-string/issues/298
430
+ // object: StringifiableRecord,
431
+ object: Record<string, any>,
432
+ options?: StringifyOptions
433
+ ): string;
434
+
435
+ /**
436
+ Extract a query string from a URL that can be passed into `.parse()`.
437
+
438
+ Note: This behaviour can be changed with the `skipNull` option.
439
+ */
440
+ export function extract(url: string): string;
441
+
442
+ export type UrlObject = {
443
+ readonly url: string;
444
+
445
+ /**
446
+ Overrides queries in the `url` property.
447
+ */
448
+ readonly query?: StringifiableRecord;
449
+
450
+ /**
451
+ Overrides the fragment identifier in the `url` property.
452
+ */
453
+ readonly fragmentIdentifier?: string;
454
+ };
455
+
456
+ /**
457
+ Stringify an object into a URL with a query string and sorting the keys. The inverse of [`.parseUrl()`](https://github.com/sindresorhus/query-string#parseurlstring-options)
458
+
459
+ Query items in the `query` property overrides queries in the `url` property.
460
+
461
+ The `fragmentIdentifier` property overrides the fragment identifier in the `url` property.
462
+
463
+ @example
464
+ ```
465
+ queryString.stringifyUrl({url: 'https://foo.bar', query: {foo: 'bar'}});
466
+ //=> 'https://foo.bar?foo=bar'
467
+
468
+ queryString.stringifyUrl({url: 'https://foo.bar?foo=baz', query: {foo: 'bar'}});
469
+ //=> 'https://foo.bar?foo=bar'
470
+
471
+ queryString.stringifyUrl({
472
+ url: 'https://foo.bar',
473
+ query: {
474
+ top: 'foo'
475
+ },
476
+ fragmentIdentifier: 'bar'
477
+ });
478
+ //=> 'https://foo.bar?top=foo#bar'
479
+ ```
480
+ */
481
+ export function stringifyUrl(
482
+ object: UrlObject,
483
+ options?: StringifyOptions
484
+ ): string;
485
+
486
+ /**
487
+ Pick query parameters from a URL.
488
+
489
+ @param url - The URL containing the query parameters to pick.
490
+ @param keys - The names of the query parameters to keep. All other query parameters will be removed from the URL.
491
+ @param filter - A filter predicate that will be provided the name of each query parameter and its value. The `parseNumbers` and `parseBooleans` options also affect `value`.
492
+
493
+ @returns The URL with the picked query parameters.
494
+
495
+ @example
496
+ ```
497
+ queryString.pick('https://foo.bar?foo=1&bar=2#hello', ['foo']);
498
+ //=> 'https://foo.bar?foo=1#hello'
499
+
500
+ queryString.pick('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
501
+ //=> 'https://foo.bar?bar=2#hello'
502
+ ```
503
+ */
504
+ export function pick(
505
+ url: string,
506
+ keys: readonly string[],
507
+ options?: ParseOptions & StringifyOptions
508
+ ): string;
509
+ export function pick(
510
+ url: string,
511
+ filter: (key: string, value: string | boolean | number) => boolean,
512
+ options?: {parseBooleans: true; parseNumbers: true} & ParseOptions & StringifyOptions
513
+ ): string;
514
+ export function pick(
515
+ url: string,
516
+ filter: (key: string, value: string | boolean) => boolean,
517
+ options?: {parseBooleans: true} & ParseOptions & StringifyOptions
518
+ ): string;
519
+ export function pick(
520
+ url: string,
521
+ filter: (key: string, value: string | number) => boolean,
522
+ options?: {parseNumbers: true} & ParseOptions & StringifyOptions
523
+ ): string;
524
+
525
+ /**
526
+ Exclude query parameters from a URL. Like `.pick()` but reversed.
527
+
528
+ @param url - The URL containing the query parameters to exclude.
529
+ @param keys - The names of the query parameters to remove. All other query parameters will remain in the URL.
530
+ @param filter - A filter predicate that will be provided the name of each query parameter and its value. The `parseNumbers` and `parseBooleans` options also affect `value`.
531
+
532
+ @returns The URL without the excluded the query parameters.
533
+
534
+ @example
535
+ ```
536
+ queryString.exclude('https://foo.bar?foo=1&bar=2#hello', ['foo']);
537
+ //=> 'https://foo.bar?bar=2#hello'
538
+
539
+ queryString.exclude('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
540
+ //=> 'https://foo.bar?foo=1#hello'
541
+ ```
542
+ */
543
+ export function exclude(
544
+ url: string,
545
+ keys: readonly string[],
546
+ options?: ParseOptions & StringifyOptions
547
+ ): string;
548
+ export function exclude(
549
+ url: string,
550
+ filter: (key: string, value: string | boolean | number) => boolean,
551
+ options?: {parseBooleans: true; parseNumbers: true} & ParseOptions & StringifyOptions
552
+ ): string;
553
+ export function exclude(
554
+ url: string,
555
+ filter: (key: string, value: string | boolean) => boolean,
556
+ options?: {parseBooleans: true} & ParseOptions & StringifyOptions
557
+ ): string;
558
+ export function exclude(
559
+ url: string,
560
+ filter: (key: string, value: string | number) => boolean,
561
+ options?: {parseNumbers: true} & ParseOptions & StringifyOptions
562
+ ): string;
package/base.js ADDED
@@ -0,0 +1,673 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ extract: function() {
13
+ return extract;
14
+ },
15
+ parse: function() {
16
+ return parse;
17
+ },
18
+ stringify: function() {
19
+ return stringify;
20
+ },
21
+ parseUrl: function() {
22
+ return parseUrl;
23
+ },
24
+ stringifyUrl: function() {
25
+ return stringifyUrl;
26
+ },
27
+ pick: function() {
28
+ return pick;
29
+ },
30
+ exclude: function() {
31
+ return exclude;
32
+ }
33
+ });
34
+ var _decodeUriComponent = /*#__PURE__*/ _interopRequireDefault(require("decode-uri-component"));
35
+ var _splitOnFirst = /*#__PURE__*/ _interopRequireDefault(require("split-on-first"));
36
+ var _filterObj = require("filter-obj");
37
+ function _arrayLikeToArray(arr, len) {
38
+ if (len == null || len > arr.length) len = arr.length;
39
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40
+ return arr2;
41
+ }
42
+ function _arrayWithHoles(arr) {
43
+ if (Array.isArray(arr)) return arr;
44
+ }
45
+ function _arrayWithoutHoles(arr) {
46
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
47
+ }
48
+ function _defineProperty(obj, key, value) {
49
+ if (key in obj) {
50
+ Object.defineProperty(obj, key, {
51
+ value: value,
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true
55
+ });
56
+ } else {
57
+ obj[key] = value;
58
+ }
59
+ return obj;
60
+ }
61
+ function _interopRequireDefault(obj) {
62
+ return obj && obj.__esModule ? obj : {
63
+ default: obj
64
+ };
65
+ }
66
+ function _iterableToArray(iter) {
67
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
68
+ }
69
+ function _iterableToArrayLimit(arr, i) {
70
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
71
+ if (_i == null) return;
72
+ var _arr = [];
73
+ var _n = true;
74
+ var _d = false;
75
+ var _s, _e;
76
+ try {
77
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
78
+ _arr.push(_s.value);
79
+ if (i && _arr.length === i) break;
80
+ }
81
+ } catch (err) {
82
+ _d = true;
83
+ _e = err;
84
+ } finally{
85
+ try {
86
+ if (!_n && _i["return"] != null) _i["return"]();
87
+ } finally{
88
+ if (_d) throw _e;
89
+ }
90
+ }
91
+ return _arr;
92
+ }
93
+ function _nonIterableRest() {
94
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95
+ }
96
+ function _nonIterableSpread() {
97
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
+ }
99
+ function _objectSpread(target) {
100
+ for(var i = 1; i < arguments.length; i++){
101
+ var source = arguments[i] != null ? arguments[i] : {};
102
+ var ownKeys = Object.keys(source);
103
+ if (typeof Object.getOwnPropertySymbols === "function") {
104
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
105
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
106
+ }));
107
+ }
108
+ ownKeys.forEach(function(key) {
109
+ _defineProperty(target, key, source[key]);
110
+ });
111
+ }
112
+ return target;
113
+ }
114
+ function _slicedToArray(arr, i) {
115
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
116
+ }
117
+ function _toConsumableArray(arr) {
118
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
119
+ }
120
+ function _unsupportedIterableToArray(o, minLen) {
121
+ if (!o) return;
122
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
123
+ var n = Object.prototype.toString.call(o).slice(8, -1);
124
+ if (n === "Object" && o.constructor) n = o.constructor.name;
125
+ if (n === "Map" || n === "Set") return Array.from(n);
126
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
127
+ }
128
+ var isNullOrUndefined = function(value) {
129
+ return value === null || value === undefined;
130
+ };
131
+ // eslint-disable-next-line unicorn/prefer-code-point
132
+ var strictUriEncode = function(string) {
133
+ return encodeURIComponent(string).replace(/[!'()*]/g, function(x) {
134
+ return "%".concat(x.charCodeAt(0).toString(16).toUpperCase());
135
+ });
136
+ };
137
+ var encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier");
138
+ function encoderForArrayFormat(options) {
139
+ switch(options.arrayFormat){
140
+ case "index":
141
+ {
142
+ return function(key) {
143
+ return function(result, value) {
144
+ var index = result.length;
145
+ if (value === undefined || options.skipNull && value === null || options.skipEmptyString && value === "") {
146
+ return result;
147
+ }
148
+ if (value === null) {
149
+ return _toConsumableArray(result).concat([
150
+ [
151
+ encode(key, options),
152
+ "[",
153
+ index,
154
+ "]"
155
+ ].join(""),
156
+ ]);
157
+ }
158
+ return _toConsumableArray(result).concat([
159
+ [
160
+ encode(key, options),
161
+ "[",
162
+ encode(index, options),
163
+ "]=",
164
+ encode(value, options)
165
+ ].join(""),
166
+ ]);
167
+ };
168
+ };
169
+ }
170
+ case "bracket":
171
+ {
172
+ return function(key) {
173
+ return function(result, value) {
174
+ if (value === undefined || options.skipNull && value === null || options.skipEmptyString && value === "") {
175
+ return result;
176
+ }
177
+ if (value === null) {
178
+ return _toConsumableArray(result).concat([
179
+ [
180
+ encode(key, options),
181
+ "[]"
182
+ ].join(""),
183
+ ]);
184
+ }
185
+ return _toConsumableArray(result).concat([
186
+ [
187
+ encode(key, options),
188
+ "[]=",
189
+ encode(value, options)
190
+ ].join(""),
191
+ ]);
192
+ };
193
+ };
194
+ }
195
+ case "colon-list-separator":
196
+ {
197
+ return function(key) {
198
+ return function(result, value) {
199
+ if (value === undefined || options.skipNull && value === null || options.skipEmptyString && value === "") {
200
+ return result;
201
+ }
202
+ if (value === null) {
203
+ return _toConsumableArray(result).concat([
204
+ [
205
+ encode(key, options),
206
+ ":list="
207
+ ].join(""),
208
+ ]);
209
+ }
210
+ return _toConsumableArray(result).concat([
211
+ [
212
+ encode(key, options),
213
+ ":list=",
214
+ encode(value, options)
215
+ ].join(""),
216
+ ]);
217
+ };
218
+ };
219
+ }
220
+ case "comma":
221
+ case "separator":
222
+ case "bracket-separator":
223
+ {
224
+ var keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
225
+ return function(key) {
226
+ return function(result, value) {
227
+ if (value === undefined || options.skipNull && value === null || options.skipEmptyString && value === "") {
228
+ return result;
229
+ }
230
+ // Translate null to an empty string so that it doesn't serialize as 'null'
231
+ value = value === null ? "" : value;
232
+ if (result.length === 0) {
233
+ return [
234
+ [
235
+ encode(key, options),
236
+ keyValueSep,
237
+ encode(value, options)
238
+ ].join("")
239
+ ];
240
+ }
241
+ return [
242
+ [
243
+ result,
244
+ encode(value, options)
245
+ ].join(options.arrayFormatSeparator)
246
+ ];
247
+ };
248
+ };
249
+ }
250
+ default:
251
+ {
252
+ return function(key) {
253
+ return function(result, value) {
254
+ if (value === undefined || options.skipNull && value === null || options.skipEmptyString && value === "") {
255
+ return result;
256
+ }
257
+ if (value === null) {
258
+ return _toConsumableArray(result).concat([
259
+ encode(key, options),
260
+ ]);
261
+ }
262
+ return _toConsumableArray(result).concat([
263
+ [
264
+ encode(key, options),
265
+ "=",
266
+ encode(value, options)
267
+ ].join(""),
268
+ ]);
269
+ };
270
+ };
271
+ }
272
+ }
273
+ }
274
+ function parserForArrayFormat(options) {
275
+ var result;
276
+ switch(options.arrayFormat){
277
+ case "index":
278
+ {
279
+ return function(key, value, accumulator) {
280
+ result = /\[(\d*)]$/.exec(key);
281
+ key = key.replace(/\[\d*]$/, "");
282
+ if (!result) {
283
+ accumulator[key] = value;
284
+ return;
285
+ }
286
+ if (accumulator[key] === undefined) {
287
+ accumulator[key] = {};
288
+ }
289
+ accumulator[key][result[1]] = value;
290
+ };
291
+ }
292
+ case "bracket":
293
+ {
294
+ return function(key, value, accumulator) {
295
+ result = /(\[])$/.exec(key);
296
+ key = key.replace(/\[]$/, "");
297
+ if (!result) {
298
+ accumulator[key] = value;
299
+ return;
300
+ }
301
+ if (accumulator[key] === undefined) {
302
+ accumulator[key] = [
303
+ value
304
+ ];
305
+ return;
306
+ }
307
+ accumulator[key] = _toConsumableArray(accumulator[key]).concat([
308
+ value
309
+ ]);
310
+ };
311
+ }
312
+ case "colon-list-separator":
313
+ {
314
+ return function(key, value, accumulator) {
315
+ result = /(:list)$/.exec(key);
316
+ key = key.replace(/:list$/, "");
317
+ if (!result) {
318
+ accumulator[key] = value;
319
+ return;
320
+ }
321
+ if (accumulator[key] === undefined) {
322
+ accumulator[key] = [
323
+ value
324
+ ];
325
+ return;
326
+ }
327
+ accumulator[key] = _toConsumableArray(accumulator[key]).concat([
328
+ value
329
+ ]);
330
+ };
331
+ }
332
+ case "comma":
333
+ case "separator":
334
+ {
335
+ return function(key, value, accumulator) {
336
+ var isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator);
337
+ var isEncodedArray = typeof value === "string" && !isArray && decode(value, options).includes(options.arrayFormatSeparator);
338
+ value = isEncodedArray ? decode(value, options) : value;
339
+ var newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(function(item) {
340
+ return decode(item, options);
341
+ }) : value === null ? value : decode(value, options);
342
+ accumulator[key] = newValue;
343
+ };
344
+ }
345
+ case "bracket-separator":
346
+ {
347
+ return function(key, value, accumulator) {
348
+ var isArray = /(\[])$/.test(key);
349
+ key = key.replace(/\[]$/, "");
350
+ if (!isArray) {
351
+ accumulator[key] = value ? decode(value, options) : value;
352
+ return;
353
+ }
354
+ var arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map(function(item) {
355
+ return decode(item, options);
356
+ });
357
+ if (accumulator[key] === undefined) {
358
+ accumulator[key] = arrayValue;
359
+ return;
360
+ }
361
+ accumulator[key] = _toConsumableArray(accumulator[key]).concat(_toConsumableArray(arrayValue));
362
+ };
363
+ }
364
+ default:
365
+ {
366
+ return function(key, value, accumulator) {
367
+ if (accumulator[key] === undefined) {
368
+ accumulator[key] = value;
369
+ return;
370
+ }
371
+ accumulator[key] = _toConsumableArray([
372
+ accumulator[key]
373
+ ].flat()).concat([
374
+ value
375
+ ]);
376
+ };
377
+ }
378
+ }
379
+ }
380
+ function validateArrayFormatSeparator(value) {
381
+ if (typeof value !== "string" || value.length !== 1) {
382
+ throw new TypeError("arrayFormatSeparator must be single character string");
383
+ }
384
+ }
385
+ function encode(value, options) {
386
+ if (options.encode) {
387
+ return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
388
+ }
389
+ return value;
390
+ }
391
+ function decode(value, options) {
392
+ if (options.decode) {
393
+ return (0, _decodeUriComponent.default)(value);
394
+ }
395
+ return value;
396
+ }
397
+ function keysSorter(input) {
398
+ if (Array.isArray(input)) {
399
+ return input.sort();
400
+ }
401
+ if (typeof input === "object") {
402
+ return keysSorter(Object.keys(input)).sort(function(a, b) {
403
+ return Number(a) - Number(b);
404
+ }).map(function(key) {
405
+ return input[key];
406
+ });
407
+ }
408
+ return input;
409
+ }
410
+ function removeHash(input) {
411
+ var hashStart = input.indexOf("#");
412
+ if (hashStart !== -1) {
413
+ input = input.slice(0, hashStart);
414
+ }
415
+ return input;
416
+ }
417
+ function getHash(url) {
418
+ var hash = "";
419
+ var hashStart = url.indexOf("#");
420
+ if (hashStart !== -1) {
421
+ hash = url.slice(hashStart);
422
+ }
423
+ return hash;
424
+ }
425
+ function parseValue(value, options) {
426
+ if (options.parseNumbers && !Number.isNaN(Number(value)) && typeof value === "string" && value.trim() !== "") {
427
+ value = Number(value);
428
+ } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
429
+ value = value.toLowerCase() === "true";
430
+ }
431
+ return value;
432
+ }
433
+ function extract(input) {
434
+ input = removeHash(input);
435
+ var queryStart = input.indexOf("?");
436
+ if (queryStart === -1) {
437
+ return "";
438
+ }
439
+ return input.slice(queryStart + 1);
440
+ }
441
+ function parse(query, options) {
442
+ options = _objectSpread({
443
+ decode: true,
444
+ sort: true,
445
+ arrayFormat: "none",
446
+ arrayFormatSeparator: ",",
447
+ parseNumbers: false,
448
+ parseBooleans: false
449
+ }, options);
450
+ validateArrayFormatSeparator(options.arrayFormatSeparator);
451
+ var formatter = parserForArrayFormat(options);
452
+ // Create an object with no prototype
453
+ var returnValue = Object.create(null);
454
+ if (typeof query !== "string") {
455
+ return returnValue;
456
+ }
457
+ query = query.trim().replace(/^[?#&]/, "");
458
+ if (!query) {
459
+ return returnValue;
460
+ }
461
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
462
+ try {
463
+ for(var _iterator = query.split("&")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
464
+ var parameter = _step.value;
465
+ if (parameter === "") {
466
+ continue;
467
+ }
468
+ var parameter_ = options.decode ? parameter.replace(/\+/g, " ") : parameter;
469
+ var ref = _slicedToArray((0, _splitOnFirst.default)(parameter_, "="), 2), key = ref[0], value = ref[1];
470
+ if (key === undefined) {
471
+ key = parameter_;
472
+ }
473
+ // Missing `=` should be `null`:
474
+ // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
475
+ value = value === undefined ? null : [
476
+ "comma",
477
+ "separator",
478
+ "bracket-separator"
479
+ ].includes(options.arrayFormat) ? value : decode(value, options);
480
+ formatter(decode(key, options), value, returnValue);
481
+ }
482
+ } catch (err) {
483
+ _didIteratorError = true;
484
+ _iteratorError = err;
485
+ } finally{
486
+ try {
487
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
488
+ _iterator.return();
489
+ }
490
+ } finally{
491
+ if (_didIteratorError) {
492
+ throw _iteratorError;
493
+ }
494
+ }
495
+ }
496
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
497
+ try {
498
+ for(var _iterator1 = Object.entries(returnValue)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
499
+ var _value = _slicedToArray(_step1.value, 2), key1 = _value[0], value1 = _value[1];
500
+ if (typeof value1 === "object" && value1 !== null) {
501
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
502
+ try {
503
+ for(var _iterator2 = Object.entries(value1)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
504
+ var _value1 = _slicedToArray(_step2.value, 2), key2 = _value1[0], value2 = _value1[1];
505
+ value1[key2] = parseValue(value2, options);
506
+ }
507
+ } catch (err) {
508
+ _didIteratorError2 = true;
509
+ _iteratorError2 = err;
510
+ } finally{
511
+ try {
512
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
513
+ _iterator2.return();
514
+ }
515
+ } finally{
516
+ if (_didIteratorError2) {
517
+ throw _iteratorError2;
518
+ }
519
+ }
520
+ }
521
+ } else {
522
+ returnValue[key1] = parseValue(value1, options);
523
+ }
524
+ }
525
+ } catch (err) {
526
+ _didIteratorError1 = true;
527
+ _iteratorError1 = err;
528
+ } finally{
529
+ try {
530
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
531
+ _iterator1.return();
532
+ }
533
+ } finally{
534
+ if (_didIteratorError1) {
535
+ throw _iteratorError1;
536
+ }
537
+ }
538
+ }
539
+ if (options.sort === false) {
540
+ return returnValue;
541
+ }
542
+ // TODO: Remove the use of `reduce`.
543
+ // eslint-disable-next-line unicorn/no-array-reduce
544
+ return (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce(function(result, key) {
545
+ var value = returnValue[key];
546
+ if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) {
547
+ // Sort object keys, not values
548
+ result[key] = keysSorter(value);
549
+ } else {
550
+ result[key] = value;
551
+ }
552
+ return result;
553
+ }, Object.create(null));
554
+ }
555
+ function stringify(object, options) {
556
+ if (!object) {
557
+ return "";
558
+ }
559
+ options = _objectSpread({
560
+ encode: true,
561
+ strict: true,
562
+ arrayFormat: "none",
563
+ arrayFormatSeparator: ","
564
+ }, options);
565
+ validateArrayFormatSeparator(options.arrayFormatSeparator);
566
+ var shouldFilter = function(key) {
567
+ return options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === "";
568
+ };
569
+ var formatter = encoderForArrayFormat(options);
570
+ var objectCopy = {};
571
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
572
+ try {
573
+ for(var _iterator = Object.entries(object)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
574
+ var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
575
+ if (!shouldFilter(key)) {
576
+ objectCopy[key] = value;
577
+ }
578
+ }
579
+ } catch (err) {
580
+ _didIteratorError = true;
581
+ _iteratorError = err;
582
+ } finally{
583
+ try {
584
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
585
+ _iterator.return();
586
+ }
587
+ } finally{
588
+ if (_didIteratorError) {
589
+ throw _iteratorError;
590
+ }
591
+ }
592
+ }
593
+ var keys = Object.keys(objectCopy);
594
+ if (options.sort !== false) {
595
+ keys.sort(options.sort);
596
+ }
597
+ return keys.map(function(key) {
598
+ var value = object[key];
599
+ if (value === undefined) {
600
+ return "";
601
+ }
602
+ if (value === null) {
603
+ return encode(key, options);
604
+ }
605
+ if (Array.isArray(value)) {
606
+ if (value.length === 0 && options.arrayFormat === "bracket-separator") {
607
+ return encode(key, options) + "[]";
608
+ }
609
+ return value.reduce(formatter(key), []).join("&");
610
+ }
611
+ return encode(key, options) + "=" + encode(value, options);
612
+ }).filter(function(x) {
613
+ return x.length > 0;
614
+ }).join("&");
615
+ }
616
+ function parseUrl(url, options) {
617
+ var ref;
618
+ options = _objectSpread({
619
+ decode: true
620
+ }, options);
621
+ var ref1 = _slicedToArray((0, _splitOnFirst.default)(url, "#"), 2), url_ = ref1[0], hash = ref1[1];
622
+ if (url_ === undefined) {
623
+ url_ = url;
624
+ }
625
+ var ref2;
626
+ return _objectSpread({
627
+ url: (ref2 = (ref = url_ === null || url_ === void 0 ? void 0 : url_.split("?")) === null || ref === void 0 ? void 0 : ref[0]) !== null && ref2 !== void 0 ? ref2 : "",
628
+ query: parse(extract(url), options)
629
+ }, options && options.parseFragmentIdentifier && hash ? {
630
+ fragmentIdentifier: decode(hash, options)
631
+ } : {});
632
+ }
633
+ function stringifyUrl(object, options) {
634
+ options = _objectSpread(_defineProperty({
635
+ encode: true,
636
+ strict: true
637
+ }, encodeFragmentIdentifier, true), options);
638
+ var url = removeHash(object.url).split("?")[0] || "";
639
+ var queryFromUrl = extract(object.url);
640
+ var query = _objectSpread({}, parse(queryFromUrl, {
641
+ sort: false
642
+ }), object.query);
643
+ var queryString = stringify(query, options);
644
+ if (queryString) {
645
+ queryString = "?".concat(queryString);
646
+ }
647
+ var hash = getHash(object.url);
648
+ if (object.fragmentIdentifier) {
649
+ var urlObjectForFragmentEncode = new URL(url);
650
+ urlObjectForFragmentEncode.hash = object.fragmentIdentifier;
651
+ hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : "#".concat(object.fragmentIdentifier);
652
+ }
653
+ return "".concat(url).concat(queryString).concat(hash);
654
+ }
655
+ function pick(input, filter, options) {
656
+ options = _objectSpread(_defineProperty({
657
+ parseFragmentIdentifier: true
658
+ }, encodeFragmentIdentifier, false), options);
659
+ var ref = parseUrl(input, options), url = ref.url, query = ref.query, fragmentIdentifier = ref.fragmentIdentifier;
660
+ return stringifyUrl({
661
+ url: url,
662
+ query: (0, _filterObj.includeKeys)(query, filter),
663
+ fragmentIdentifier: fragmentIdentifier
664
+ }, options);
665
+ }
666
+ function exclude(input, filter, options) {
667
+ var exclusionFilter = Array.isArray(filter) ? function(key) {
668
+ return !filter.includes(key);
669
+ } : function(key, value) {
670
+ return !filter(key, value);
671
+ };
672
+ return pick(input, exclusionFilter, options);
673
+ }
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /// export * as default from './base.js';
2
+
3
+ // Workaround for TS missing feature.
4
+ import * as queryString from './base.js';
5
+
6
+ export default queryString;
7
+
8
+ export {
9
+ type ParseOptions,
10
+ type ParsedQuery,
11
+ type ParsedUrl,
12
+ type StringifyOptions,
13
+ type Stringifiable,
14
+ type StringifiableRecord,
15
+ type UrlObject,
16
+ } from './base.js';
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ var _baseJs = /*#__PURE__*/ _interopRequireWildcard(require("./base.js"));
12
+ function _getRequireWildcardCache(nodeInterop) {
13
+ if (typeof WeakMap !== "function") return null;
14
+ var cacheBabelInterop = new WeakMap();
15
+ var cacheNodeInterop = new WeakMap();
16
+ return (_getRequireWildcardCache = function(nodeInterop) {
17
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
+ })(nodeInterop);
19
+ }
20
+ function _interopRequireWildcard(obj, nodeInterop) {
21
+ if (!nodeInterop && obj && obj.__esModule) {
22
+ return obj;
23
+ }
24
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
+ return {
26
+ default: obj
27
+ };
28
+ }
29
+ var cache = _getRequireWildcardCache(nodeInterop);
30
+ if (cache && cache.has(obj)) {
31
+ return cache.get(obj);
32
+ }
33
+ var newObj = {};
34
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
35
+ for(var key in obj){
36
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
37
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
38
+ if (desc && (desc.get || desc.set)) {
39
+ Object.defineProperty(newObj, key, desc);
40
+ } else {
41
+ newObj[key] = obj[key];
42
+ }
43
+ }
44
+ }
45
+ newObj.default = obj;
46
+ if (cache) {
47
+ cache.set(obj, newObj);
48
+ }
49
+ return newObj;
50
+ }
51
+ var _default = _baseJs;
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@common.js/query-string",
3
+ "version": "8.1.0",
4
+ "description": "query-string package exported as CommonJS modules",
5
+ "license": "MIT",
6
+ "repository": "etienne-martin/common.js",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "type": "commonjs",
9
+ "engines": {
10
+ "node": ">=14.16"
11
+ },
12
+ "scripts": {
13
+ "benchmark": "node benchmark.js",
14
+ "test": "xo && ava && tsd"
15
+ },
16
+ "files": [
17
+ "index.js",
18
+ "index.d.ts",
19
+ "base.js",
20
+ "base.d.ts"
21
+ ],
22
+ "dependencies": {
23
+ "@common.js/decode-uri-component": "^0.4.1",
24
+ "@common.js/filter-obj": "^5.1.0",
25
+ "@common.js/split-on-first": "^3.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "ava": "^5.1.0",
29
+ "benchmark": "^2.1.4",
30
+ "deep-equal": "^2.1.0",
31
+ "fast-check": "^3.4.0",
32
+ "tsd": "^0.25.0",
33
+ "xo": "^0.53.1"
34
+ },
35
+ "tsd": {
36
+ "compilerOptions": {
37
+ "module": "node16"
38
+ }
39
+ },
40
+ "homepage": "https://github.com/etienne-martin/common.js#readme",
41
+ "types": "./index.d.ts",
42
+ "main": "./index.js"
43
+ }