@nocobase/plugin-multi-keyword-filter 2.2.17 → 2.2.18

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.
Files changed (46) hide show
  1. package/dist/client/103.b39ee70786cb13a7.js +10 -0
  2. package/dist/client/index.js +1 -1
  3. package/dist/client-v2/103.dfed67c95bcd8a1d.js +10 -0
  4. package/dist/client-v2/index.js +1 -1
  5. package/dist/externalVersion.js +4 -4
  6. package/dist/node_modules/qs/.editorconfig +4 -1
  7. package/dist/node_modules/qs/.github/SECURITY.md +11 -0
  8. package/dist/node_modules/qs/.github/THREAT_MODEL.md +78 -0
  9. package/dist/node_modules/qs/dist/qs.js +90 -2036
  10. package/dist/node_modules/qs/lib/index.js +1 -1
  11. package/dist/node_modules/qs/lib/parse.js +215 -66
  12. package/dist/node_modules/qs/lib/stringify.js +90 -32
  13. package/dist/node_modules/qs/lib/utils.js +189 -53
  14. package/dist/node_modules/qs/node_modules/es-define-property/.eslintrc +13 -0
  15. package/dist/node_modules/qs/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  16. package/dist/node_modules/qs/node_modules/es-define-property/.nycrc +9 -0
  17. package/dist/node_modules/qs/node_modules/es-define-property/index.d.ts +3 -0
  18. package/dist/node_modules/qs/node_modules/es-define-property/index.js +14 -0
  19. package/dist/node_modules/qs/node_modules/es-define-property/package.json +81 -0
  20. package/dist/node_modules/qs/node_modules/es-define-property/test/index.js +56 -0
  21. package/dist/node_modules/qs/node_modules/side-channel/.editorconfig +9 -0
  22. package/dist/node_modules/qs/node_modules/side-channel/.eslintrc +12 -0
  23. package/dist/node_modules/qs/node_modules/side-channel/.github/FUNDING.yml +12 -0
  24. package/dist/node_modules/qs/node_modules/side-channel/.nycrc +13 -0
  25. package/dist/node_modules/qs/node_modules/side-channel/index.d.ts +14 -0
  26. package/dist/node_modules/qs/node_modules/side-channel/index.js +46 -0
  27. package/dist/node_modules/qs/node_modules/side-channel/package.json +85 -0
  28. package/dist/node_modules/qs/node_modules/side-channel/test/index.js +120 -0
  29. package/dist/node_modules/qs/node_modules/side-channel-list/.editorconfig +9 -0
  30. package/dist/node_modules/qs/node_modules/side-channel-list/.eslintrc +11 -0
  31. package/dist/node_modules/qs/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  32. package/dist/node_modules/qs/node_modules/side-channel-list/.nycrc +13 -0
  33. package/dist/node_modules/qs/node_modules/side-channel-list/index.d.ts +13 -0
  34. package/dist/node_modules/qs/node_modules/side-channel-list/index.js +111 -0
  35. package/dist/node_modules/qs/node_modules/side-channel-list/list.d.ts +14 -0
  36. package/dist/node_modules/qs/node_modules/side-channel-list/package.json +77 -0
  37. package/dist/node_modules/qs/node_modules/side-channel-list/test/index.js +154 -0
  38. package/dist/node_modules/qs/package.json +1 -1
  39. package/dist/node_modules/qs/test/empty-keys-cases.js +261 -31
  40. package/dist/node_modules/qs/test/parse.js +1281 -57
  41. package/dist/node_modules/qs/test/stringify.js +851 -58
  42. package/dist/node_modules/qs/test/utils.js +505 -3
  43. package/package.json +5 -2
  44. package/dist/client/103.513149b773e262dc.js +0 -10
  45. package/dist/client-v2/103.8bcbf628d0af8457.js +0 -10
  46. package/dist/node_modules/qs/.eslintrc +0 -38
@@ -30,12 +30,18 @@ var defaultFormat = formats['default'];
30
30
  var defaults = {
31
31
  addQueryPrefix: false,
32
32
  allowDots: false,
33
+ allowEmptyArrays: false,
34
+ arrayFormat: 'indices',
33
35
  charset: 'utf-8',
34
36
  charsetSentinel: false,
37
+ commaRoundTrip: false,
35
38
  delimiter: '&',
39
+ depth: Infinity,
36
40
  encode: true,
41
+ encodeDotInKeys: false,
37
42
  encoder: utils.encode,
38
43
  encodeValuesOnly: false,
44
+ filter: void undefined,
39
45
  format: defaultFormat,
40
46
  formatter: formats.formatters[defaultFormat],
41
47
  // deprecated
@@ -62,8 +68,10 @@ var stringify = function stringify(
62
68
  prefix,
63
69
  generateArrayPrefix,
64
70
  commaRoundTrip,
71
+ allowEmptyArrays,
65
72
  strictNullHandling,
66
73
  skipNulls,
74
+ encodeDotInKeys,
67
75
  encoder,
68
76
  filter,
69
77
  sort,
@@ -73,10 +81,16 @@ var stringify = function stringify(
73
81
  formatter,
74
82
  encodeValuesOnly,
75
83
  charset,
76
- sideChannel
84
+ sideChannel,
85
+ depth,
86
+ currentDepth
77
87
  ) {
78
88
  var obj = object;
79
89
 
90
+ if (currentDepth > depth) {
91
+ throw new RangeError('Input depth exceeded depth option of ' + depth);
92
+ }
93
+
80
94
  var tmpSc = sideChannel;
81
95
  var step = 0;
82
96
  var findFlag = false;
@@ -96,9 +110,9 @@ var stringify = function stringify(
96
110
  }
97
111
  }
98
112
 
99
- if (typeof filter === 'function') {
100
- obj = filter(prefix, obj);
101
- } else if (obj instanceof Date) {
113
+ obj = typeof filter === 'function' ? filter(prefix, obj) : obj;
114
+
115
+ if (obj instanceof Date) {
102
116
  obj = serializeDate(obj);
103
117
  } else if (generateArrayPrefix === 'comma' && isArray(obj)) {
104
118
  obj = utils.maybeMap(obj, function (value) {
@@ -111,7 +125,7 @@ var stringify = function stringify(
111
125
 
112
126
  if (obj === null) {
113
127
  if (strictNullHandling) {
114
- return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
128
+ return formatter(encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix);
115
129
  }
116
130
 
117
131
  obj = '';
@@ -135,7 +149,9 @@ var stringify = function stringify(
135
149
  if (generateArrayPrefix === 'comma' && isArray(obj)) {
136
150
  // we need to join elements in
137
151
  if (encodeValuesOnly && encoder) {
138
- obj = utils.maybeMap(obj, encoder);
152
+ obj = utils.maybeMap(obj, function (v) {
153
+ return v == null ? v : encoder(v);
154
+ });
139
155
  }
140
156
  objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
141
157
  } else if (isArray(filter)) {
@@ -145,19 +161,28 @@ var stringify = function stringify(
145
161
  objKeys = sort ? keys.sort(sort) : keys;
146
162
  }
147
163
 
148
- var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
164
+ var encodedPrefix = encodeDotInKeys ? String(prefix).replace(/\./g, '%2E') : String(prefix);
165
+
166
+ var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + '[]' : encodedPrefix;
167
+
168
+ if (allowEmptyArrays && isArray(obj) && obj.length === 0 && Object.keys(obj).length === 0) {
169
+ return adjustedPrefix + '[]';
170
+ }
149
171
 
150
172
  for (var j = 0; j < objKeys.length; ++j) {
151
173
  var key = objKeys[j];
152
- var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
174
+ var value = typeof key === 'object' && key && typeof key.value !== 'undefined'
175
+ ? key.value
176
+ : obj[key];
153
177
 
154
178
  if (skipNulls && value === null) {
155
179
  continue;
156
180
  }
157
181
 
182
+ var encodedKey = allowDots && encodeDotInKeys ? String(key).replace(/\./g, '%2E') : String(key);
158
183
  var keyPrefix = isArray(obj)
159
- ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
160
- : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
184
+ ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix
185
+ : adjustedPrefix + (allowDots ? '.' + encodedKey : '[' + encodedKey + ']');
161
186
 
162
187
  sideChannel.set(object, step);
163
188
  var valueSideChannel = getSideChannel();
@@ -167,8 +192,10 @@ var stringify = function stringify(
167
192
  keyPrefix,
168
193
  generateArrayPrefix,
169
194
  commaRoundTrip,
195
+ allowEmptyArrays,
170
196
  strictNullHandling,
171
197
  skipNulls,
198
+ encodeDotInKeys,
172
199
  generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder,
173
200
  filter,
174
201
  sort,
@@ -178,7 +205,9 @@ var stringify = function stringify(
178
205
  formatter,
179
206
  encodeValuesOnly,
180
207
  charset,
181
- valueSideChannel
208
+ valueSideChannel,
209
+ depth,
210
+ currentDepth + 1
182
211
  ));
183
212
  }
184
213
 
@@ -190,6 +219,14 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
190
219
  return defaults;
191
220
  }
192
221
 
222
+ if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
223
+ throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
224
+ }
225
+
226
+ if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') {
227
+ throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided');
228
+ }
229
+
193
230
  if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
194
231
  throw new TypeError('Encoder has to be a function.');
195
232
  }
@@ -213,13 +250,33 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
213
250
  filter = opts.filter;
214
251
  }
215
252
 
253
+ var arrayFormat;
254
+ if (opts.arrayFormat in arrayPrefixGenerators) {
255
+ arrayFormat = opts.arrayFormat;
256
+ } else if ('indices' in opts) {
257
+ arrayFormat = opts.indices ? 'indices' : 'repeat';
258
+ } else {
259
+ arrayFormat = defaults.arrayFormat;
260
+ }
261
+
262
+ if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
263
+ throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
264
+ }
265
+
266
+ var allowDots = typeof opts.allowDots === 'undefined' ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
267
+
216
268
  return {
217
269
  addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
218
- allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
270
+ allowDots: allowDots,
271
+ allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
272
+ arrayFormat: arrayFormat,
219
273
  charset: charset,
220
274
  charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
275
+ commaRoundTrip: !!opts.commaRoundTrip,
221
276
  delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
277
+ depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth,
222
278
  encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
279
+ encodeDotInKeys: typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
223
280
  encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
224
281
  encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
225
282
  filter: filter,
@@ -253,20 +310,8 @@ module.exports = function (object, opts) {
253
310
  return '';
254
311
  }
255
312
 
256
- var arrayFormat;
257
- if (opts && opts.arrayFormat in arrayPrefixGenerators) {
258
- arrayFormat = opts.arrayFormat;
259
- } else if (opts && 'indices' in opts) {
260
- arrayFormat = opts.indices ? 'indices' : 'repeat';
261
- } else {
262
- arrayFormat = 'indices';
263
- }
264
-
265
- var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
266
- if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
267
- throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
268
- }
269
- var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
313
+ var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
314
+ var commaRoundTrip = generateArrayPrefix === 'comma' && options.commaRoundTrip;
270
315
 
271
316
  if (!objKeys) {
272
317
  objKeys = Object.keys(obj);
@@ -280,16 +325,27 @@ module.exports = function (object, opts) {
280
325
  for (var i = 0; i < objKeys.length; ++i) {
281
326
  var key = objKeys[i];
282
327
 
283
- if (options.skipNulls && obj[key] === null) {
328
+ if (typeof key === 'undefined' || key === null) {
329
+ continue;
330
+ }
331
+
332
+ var value = obj[key];
333
+
334
+ if (options.skipNulls && value === null) {
284
335
  continue;
285
336
  }
337
+
338
+ var encodedKey = options.encodeDotInKeys ? String(key).replace(/\./g, '%2E') : String(key);
339
+
286
340
  pushToArray(keys, stringify(
287
- obj[key],
288
- key,
341
+ value,
342
+ encodedKey,
289
343
  generateArrayPrefix,
290
344
  commaRoundTrip,
345
+ options.allowEmptyArrays,
291
346
  options.strictNullHandling,
292
347
  options.skipNulls,
348
+ options.encodeDotInKeys,
293
349
  options.encode ? options.encoder : null,
294
350
  options.filter,
295
351
  options.sort,
@@ -299,7 +355,9 @@ module.exports = function (object, opts) {
299
355
  options.formatter,
300
356
  options.encodeValuesOnly,
301
357
  options.charset,
302
- sideChannel
358
+ sideChannel,
359
+ options.depth,
360
+ 0
303
361
  ));
304
362
  }
305
363
 
@@ -309,10 +367,10 @@ module.exports = function (object, opts) {
309
367
  if (options.charsetSentinel) {
310
368
  if (options.charset === 'iso-8859-1') {
311
369
  // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
312
- prefix += 'utf8=%26%2310003%3B&';
370
+ prefix += 'utf8=%26%2310003%3B' + options.delimiter;
313
371
  } else {
314
372
  // encodeURIComponent('✓')
315
- prefix += 'utf8=%E2%9C%93&';
373
+ prefix += 'utf8=%E2%9C%93' + options.delimiter;
316
374
  }
317
375
  }
318
376
 
@@ -1,14 +1,37 @@
1
1
  'use strict';
2
2
 
3
3
  var formats = require('./formats');
4
+ var getSideChannel = require('side-channel');
5
+ var defineProperty = require('es-define-property');
4
6
 
5
7
  var has = Object.prototype.hasOwnProperty;
6
8
  var isArray = Array.isArray;
7
9
 
10
+ // Track objects created from arrayLimit overflow using side-channel
11
+ // Stores the current max numeric index for O(1) lookup
12
+ var overflowChannel = getSideChannel();
13
+
14
+ var markOverflow = function markOverflow(obj, maxIndex) {
15
+ overflowChannel.set(obj, maxIndex);
16
+ return obj;
17
+ };
18
+
19
+ var isOverflow = function isOverflow(obj) {
20
+ return overflowChannel.has(obj);
21
+ };
22
+
23
+ var getMaxIndex = function getMaxIndex(obj) {
24
+ return overflowChannel.get(obj);
25
+ };
26
+
27
+ var setMaxIndex = function setMaxIndex(obj, maxIndex) {
28
+ overflowChannel.set(obj, maxIndex);
29
+ };
30
+
8
31
  var hexTable = (function () {
9
32
  var array = [];
10
33
  for (var i = 0; i < 256; ++i) {
11
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
34
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
12
35
  }
13
36
 
14
37
  return array;
@@ -24,7 +47,7 @@ var compactQueue = function compactQueue(queue) {
24
47
 
25
48
  for (var j = 0; j < obj.length; ++j) {
26
49
  if (typeof obj[j] !== 'undefined') {
27
- compacted.push(obj[j]);
50
+ compacted[compacted.length] = obj[j];
28
51
  }
29
52
  }
30
53
 
@@ -34,7 +57,7 @@ var compactQueue = function compactQueue(queue) {
34
57
  };
35
58
 
36
59
  var arrayToObject = function arrayToObject(source, options) {
37
- var obj = options && options.plainObjects ? Object.create(null) : {};
60
+ var obj = options && options.plainObjects ? { __proto__: null } : {};
38
61
  for (var i = 0; i < source.length; ++i) {
39
62
  if (typeof source[i] !== 'undefined') {
40
63
  obj[i] = source[i];
@@ -44,17 +67,47 @@ var arrayToObject = function arrayToObject(source, options) {
44
67
  return obj;
45
68
  };
46
69
 
70
+ var setProperty = function setProperty(obj, key, value) {
71
+ if (key === '__proto__' && defineProperty) {
72
+ defineProperty(obj, key, {
73
+ configurable: true,
74
+ enumerable: true,
75
+ value: value,
76
+ writable: true
77
+ });
78
+ } else {
79
+ obj[key] = value;
80
+ }
81
+ };
82
+
47
83
  var merge = function merge(target, source, options) {
48
84
  /* eslint no-param-reassign: 0 */
49
85
  if (!source) {
50
86
  return target;
51
87
  }
52
88
 
53
- if (typeof source !== 'object') {
89
+ if (typeof source !== 'object' && typeof source !== 'function') {
54
90
  if (isArray(target)) {
55
- target.push(source);
91
+ var nextIndex = target.length;
92
+ if (options && typeof options.arrayLimit === 'number' && nextIndex >= options.arrayLimit) {
93
+ if (options.throwOnLimitExceeded) {
94
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
95
+ }
96
+ return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
97
+ }
98
+ target[nextIndex] = source;
56
99
  } else if (target && typeof target === 'object') {
57
- if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
100
+ if (isOverflow(target)) {
101
+ // Add at next numeric index for overflow objects
102
+ var newIndex = getMaxIndex(target) + 1;
103
+ target[newIndex] = source;
104
+ setMaxIndex(target, newIndex);
105
+ } else if (options && options.strictMerge) {
106
+ return [target, source];
107
+ } else if (
108
+ (options && (options.plainObjects || options.allowPrototypes))
109
+ || !has.call(Object.prototype, source)
110
+ ) {
58
111
  target[source] = true;
59
112
  }
60
113
  } else {
@@ -65,7 +118,26 @@ var merge = function merge(target, source, options) {
65
118
  }
66
119
 
67
120
  if (!target || typeof target !== 'object') {
68
- return [target].concat(source);
121
+ if (isOverflow(source)) {
122
+ // Create new object with target at 0, source values shifted by 1
123
+ var sourceKeys = Object.keys(source);
124
+ var result = options && options.plainObjects
125
+ ? { __proto__: null, 0: target }
126
+ : { 0: target };
127
+ for (var m = 0; m < sourceKeys.length; m++) {
128
+ var oldKey = parseInt(sourceKeys[m], 10);
129
+ result[oldKey + 1] = source[sourceKeys[m]];
130
+ }
131
+ return markOverflow(result, getMaxIndex(source) + 1);
132
+ }
133
+ var combined = [target].concat(source);
134
+ if (options && typeof options.arrayLimit === 'number' && combined.length > options.arrayLimit) {
135
+ if (options.throwOnLimitExceeded) {
136
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
137
+ }
138
+ return markOverflow(arrayToObject(combined, options), combined.length - 1);
139
+ }
140
+ return combined;
69
141
  }
70
142
 
71
143
  var mergeTarget = target;
@@ -80,12 +152,18 @@ var merge = function merge(target, source, options) {
80
152
  if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
81
153
  target[i] = merge(targetItem, item, options);
82
154
  } else {
83
- target.push(item);
155
+ target[target.length] = item;
84
156
  }
85
157
  } else {
86
158
  target[i] = item;
87
159
  }
88
160
  });
161
+ if (options && typeof options.arrayLimit === 'number' && target.length > options.arrayLimit) {
162
+ if (options.throwOnLimitExceeded) {
163
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
164
+ }
165
+ return markOverflow(arrayToObject(target, options), target.length - 1);
166
+ }
89
167
  return target;
90
168
  }
91
169
 
@@ -93,22 +171,33 @@ var merge = function merge(target, source, options) {
93
171
  var value = source[key];
94
172
 
95
173
  if (has.call(acc, key)) {
96
- acc[key] = merge(acc[key], value, options);
174
+ setProperty(acc, key, merge(acc[key], value, options));
97
175
  } else {
98
- acc[key] = value;
176
+ setProperty(acc, key, value);
99
177
  }
178
+
179
+ if (isOverflow(source) && !isOverflow(acc)) {
180
+ markOverflow(acc, getMaxIndex(source));
181
+ }
182
+ if (isOverflow(acc)) {
183
+ var keyNum = parseInt(key, 10);
184
+ if (String(keyNum) === key && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
185
+ setMaxIndex(acc, keyNum);
186
+ }
187
+ }
188
+
100
189
  return acc;
101
190
  }, mergeTarget);
102
191
  };
103
192
 
104
193
  var assign = function assignSingleSource(target, source) {
105
194
  return Object.keys(source).reduce(function (acc, key) {
106
- acc[key] = source[key];
195
+ setProperty(acc, key, source[key]);
107
196
  return acc;
108
197
  }, target);
109
198
  };
110
199
 
111
- var decode = function (str, decoder, charset) {
200
+ var decode = function (str, defaultDecoder, charset) {
112
201
  var strWithoutPlus = str.replace(/\+/g, ' ');
113
202
  if (charset === 'iso-8859-1') {
114
203
  // unescape never throws, no try...catch needed:
@@ -122,6 +211,10 @@ var decode = function (str, decoder, charset) {
122
211
  }
123
212
  };
124
213
 
214
+ var limit = 1024;
215
+
216
+ /* eslint operator-linebreak: [2, "before"] */
217
+
125
218
  var encode = function encode(str, defaultEncoder, charset, kind, format) {
126
219
  // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
127
220
  // It has been adapted here for stricter adherence to RFC 3986
@@ -143,45 +236,61 @@ var encode = function encode(str, defaultEncoder, charset, kind, format) {
143
236
  }
144
237
 
145
238
  var out = '';
146
- for (var i = 0; i < string.length; ++i) {
147
- var c = string.charCodeAt(i);
148
-
149
- if (
150
- c === 0x2D // -
151
- || c === 0x2E // .
152
- || c === 0x5F // _
153
- || c === 0x7E // ~
154
- || (c >= 0x30 && c <= 0x39) // 0-9
155
- || (c >= 0x41 && c <= 0x5A) // a-z
156
- || (c >= 0x61 && c <= 0x7A) // A-Z
157
- || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
158
- ) {
159
- out += string.charAt(i);
160
- continue;
239
+ for (var j = 0; j < string.length; j += limit) {
240
+ var segment = string.length >= limit ? string.slice(j, j + limit) : string;
241
+ if (j + limit < string.length) {
242
+ var last = segment.charCodeAt(segment.length - 1);
243
+ if (last >= 0xD800 && last <= 0xDBFF) {
244
+ segment = segment.slice(0, -1);
245
+ j -= 1;
246
+ }
161
247
  }
248
+ var arr = [];
249
+
250
+ for (var i = 0; i < segment.length; ++i) {
251
+ var c = segment.charCodeAt(i);
252
+ if (
253
+ c === 0x2D // -
254
+ || c === 0x2E // .
255
+ || c === 0x5F // _
256
+ || c === 0x7E // ~
257
+ || (c >= 0x30 && c <= 0x39) // 0-9
258
+ || (c >= 0x41 && c <= 0x5A) // a-z
259
+ || (c >= 0x61 && c <= 0x7A) // A-Z
260
+ || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
261
+ ) {
262
+ arr[arr.length] = segment.charAt(i);
263
+ continue;
264
+ }
162
265
 
163
- if (c < 0x80) {
164
- out = out + hexTable[c];
165
- continue;
166
- }
266
+ if (c < 0x80) {
267
+ arr[arr.length] = hexTable[c];
268
+ continue;
269
+ }
167
270
 
168
- if (c < 0x800) {
169
- out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
170
- continue;
171
- }
271
+ if (c < 0x800) {
272
+ arr[arr.length] = hexTable[0xC0 | (c >> 6)]
273
+ + hexTable[0x80 | (c & 0x3F)];
274
+ continue;
275
+ }
276
+
277
+ if (c < 0xD800 || c >= 0xE000) {
278
+ arr[arr.length] = hexTable[0xE0 | (c >> 12)]
279
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
280
+ + hexTable[0x80 | (c & 0x3F)];
281
+ continue;
282
+ }
283
+
284
+ i += 1;
285
+ c = 0x10000 + (((c & 0x3FF) << 10) | (segment.charCodeAt(i) & 0x3FF));
172
286
 
173
- if (c < 0xD800 || c >= 0xE000) {
174
- out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
175
- continue;
287
+ arr[arr.length] = hexTable[0xF0 | (c >> 18)]
288
+ + hexTable[0x80 | ((c >> 12) & 0x3F)]
289
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
290
+ + hexTable[0x80 | (c & 0x3F)];
176
291
  }
177
292
 
178
- i += 1;
179
- c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
180
- /* eslint operator-linebreak: [2, "before"] */
181
- out += hexTable[0xF0 | (c >> 18)]
182
- + hexTable[0x80 | ((c >> 12) & 0x3F)]
183
- + hexTable[0x80 | ((c >> 6) & 0x3F)]
184
- + hexTable[0x80 | (c & 0x3F)];
293
+ out += arr.join('');
185
294
  }
186
295
 
187
296
  return out;
@@ -189,7 +298,7 @@ var encode = function encode(str, defaultEncoder, charset, kind, format) {
189
298
 
190
299
  var compact = function compact(value) {
191
300
  var queue = [{ obj: { o: value }, prop: 'o' }];
192
- var refs = [];
301
+ var refs = getSideChannel();
193
302
 
194
303
  for (var i = 0; i < queue.length; ++i) {
195
304
  var item = queue[i];
@@ -199,9 +308,9 @@ var compact = function compact(value) {
199
308
  for (var j = 0; j < keys.length; ++j) {
200
309
  var key = keys[j];
201
310
  var val = obj[key];
202
- if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
203
- queue.push({ obj: obj, prop: key });
204
- refs.push(val);
311
+ if (typeof val === 'object' && val !== null && !refs.has(val)) {
312
+ queue[queue.length] = { obj: obj, prop: key };
313
+ refs.set(val, true);
205
314
  }
206
315
  }
207
316
  }
@@ -220,18 +329,43 @@ var isBuffer = function isBuffer(obj) {
220
329
  return false;
221
330
  }
222
331
 
223
- return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
332
+ return !!(obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj));
224
333
  };
225
334
 
226
- var combine = function combine(a, b) {
227
- return [].concat(a, b);
335
+ var combine = function combine(a, b, arrayLimit, plainObjects, throwOnLimitExceeded) {
336
+ // If 'a' is already an overflow object, add to it
337
+ if (isOverflow(a)) {
338
+ if (throwOnLimitExceeded) {
339
+ throw new RangeError('Array limit exceeded. Only ' + arrayLimit + ' element' + (arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
340
+ }
341
+ // spread `b` one level, matching the `[].concat(a, b)` used below, so a
342
+ // collection appended to an already-overflowed object is flattened
343
+ // rather than nested under a single index
344
+ var bValues = isArray(b) ? b : [b];
345
+ var newIndex = getMaxIndex(a);
346
+ for (var i = 0; i < bValues.length; ++i) {
347
+ newIndex += 1;
348
+ a[newIndex] = bValues[i];
349
+ }
350
+ setMaxIndex(a, newIndex);
351
+ return a;
352
+ }
353
+
354
+ var result = [].concat(a, b);
355
+ if (result.length > arrayLimit) {
356
+ if (throwOnLimitExceeded) {
357
+ throw new RangeError('Array limit exceeded. Only ' + arrayLimit + ' element' + (arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
358
+ }
359
+ return markOverflow(arrayToObject(result, { plainObjects: plainObjects }), result.length - 1);
360
+ }
361
+ return result;
228
362
  };
229
363
 
230
364
  var maybeMap = function maybeMap(val, fn) {
231
365
  if (isArray(val)) {
232
366
  var mapped = [];
233
367
  for (var i = 0; i < val.length; i += 1) {
234
- mapped.push(fn(val[i]));
368
+ mapped[mapped.length] = fn(val[i]);
235
369
  }
236
370
  return mapped;
237
371
  }
@@ -246,7 +380,9 @@ module.exports = {
246
380
  decode: decode,
247
381
  encode: encode,
248
382
  isBuffer: isBuffer,
383
+ isOverflow: isOverflow,
249
384
  isRegExp: isRegExp,
385
+ markOverflow: markOverflow,
250
386
  maybeMap: maybeMap,
251
387
  merge: merge
252
388
  };
@@ -0,0 +1,13 @@
1
+ {
2
+ "root": true,
3
+
4
+ "extends": "@ljharb",
5
+
6
+ "rules": {
7
+ "new-cap": ["error", {
8
+ "capIsNewExceptions": [
9
+ "GetIntrinsic",
10
+ ],
11
+ }],
12
+ },
13
+ }
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [ljharb]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: npm/es-define-property
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with a single custom sponsorship URL
@@ -0,0 +1,9 @@
1
+ {
2
+ "all": true,
3
+ "check-coverage": false,
4
+ "reporter": ["text-summary", "text", "html", "json"],
5
+ "exclude": [
6
+ "coverage",
7
+ "test"
8
+ ]
9
+ }
@@ -0,0 +1,3 @@
1
+ declare const defineProperty: false | typeof Object.defineProperty;
2
+
3
+ export = defineProperty;