superagent 8.0.1 → 8.0.3
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 +1 -0
- package/dist/superagent.js +31 -615
- package/dist/superagent.min.js +1 -1
- package/lib/agent-base.js +2 -12
- package/lib/client.js +90 -161
- package/lib/node/agent.js +10 -30
- package/lib/node/http2wrapper.js +14 -55
- package/lib/node/index.js +171 -283
- package/lib/node/parsers/image.js +1 -1
- package/lib/node/parsers/index.js +1 -3
- package/lib/node/parsers/json.js +5 -6
- package/lib/node/parsers/text.js +1 -1
- package/lib/node/parsers/urlencoded.js +2 -2
- package/lib/node/response.js +14 -19
- package/lib/node/unzip.js +14 -15
- package/lib/request-base.js +58 -107
- package/lib/response-base.js +20 -13
- package/lib/utils.js +11 -24
- package/package.json +14 -14
package/dist/superagent.js
CHANGED
|
@@ -4,18 +4,13 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
var GetIntrinsic = require('get-intrinsic');
|
|
7
|
-
|
|
8
7
|
var callBind = require('./');
|
|
9
|
-
|
|
10
8
|
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
|
11
|
-
|
|
12
9
|
module.exports = function callBoundIntrinsic(name, allowMissing) {
|
|
13
10
|
var intrinsic = GetIntrinsic(name, !!allowMissing);
|
|
14
|
-
|
|
15
11
|
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
|
|
16
12
|
return callBind(intrinsic);
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
return intrinsic;
|
|
20
15
|
};
|
|
21
16
|
|
|
@@ -23,16 +18,13 @@ module.exports = function callBoundIntrinsic(name, allowMissing) {
|
|
|
23
18
|
'use strict';
|
|
24
19
|
|
|
25
20
|
var bind = require('function-bind');
|
|
26
|
-
|
|
27
21
|
var GetIntrinsic = require('get-intrinsic');
|
|
28
|
-
|
|
29
22
|
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
|
30
23
|
var $call = GetIntrinsic('%Function.prototype.call%');
|
|
31
24
|
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
|
32
25
|
var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
|
33
26
|
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
34
27
|
var $max = GetIntrinsic('%Math.max%');
|
|
35
|
-
|
|
36
28
|
if ($defineProperty) {
|
|
37
29
|
try {
|
|
38
30
|
$defineProperty({}, 'a', {
|
|
@@ -42,27 +34,21 @@ if ($defineProperty) {
|
|
|
42
34
|
$defineProperty = null;
|
|
43
35
|
}
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
module.exports = function callBind(originalFunction) {
|
|
47
38
|
var func = $reflectApply(bind, $call, arguments);
|
|
48
|
-
|
|
49
39
|
if ($gOPD && $defineProperty) {
|
|
50
40
|
var desc = $gOPD(func, 'length');
|
|
51
|
-
|
|
52
41
|
if (desc.configurable) {
|
|
53
42
|
$defineProperty(func, 'length', {
|
|
54
43
|
value: 1 + $max(0, originalFunction.length - (arguments.length - 1))
|
|
55
44
|
});
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
return func;
|
|
60
48
|
};
|
|
61
|
-
|
|
62
49
|
var applyBind = function applyBind() {
|
|
63
50
|
return $reflectApply(bind, $apply, arguments);
|
|
64
51
|
};
|
|
65
|
-
|
|
66
52
|
if ($defineProperty) {
|
|
67
53
|
$defineProperty(module.exports, 'apply', {
|
|
68
54
|
value: applyBind
|
|
@@ -72,6 +58,8 @@ if ($defineProperty) {
|
|
|
72
58
|
}
|
|
73
59
|
|
|
74
60
|
},{"function-bind":7,"get-intrinsic":8}],4:[function(require,module,exports){
|
|
61
|
+
|
|
62
|
+
|
|
75
63
|
if (typeof module !== 'undefined') {
|
|
76
64
|
module.exports = Emitter;
|
|
77
65
|
}
|
|
@@ -79,14 +67,12 @@ if (typeof module !== 'undefined') {
|
|
|
79
67
|
function Emitter(obj) {
|
|
80
68
|
if (obj) return mixin(obj);
|
|
81
69
|
}
|
|
82
|
-
|
|
83
70
|
;
|
|
84
71
|
|
|
85
72
|
function mixin(obj) {
|
|
86
73
|
for (var key in Emitter.prototype) {
|
|
87
74
|
obj[key] = Emitter.prototype[key];
|
|
88
75
|
}
|
|
89
|
-
|
|
90
76
|
return obj;
|
|
91
77
|
}
|
|
92
78
|
|
|
@@ -101,7 +87,6 @@ Emitter.prototype.once = function (event, fn) {
|
|
|
101
87
|
this.off(event, on);
|
|
102
88
|
fn.apply(this, arguments);
|
|
103
89
|
}
|
|
104
|
-
|
|
105
90
|
on.fn = fn;
|
|
106
91
|
this.on(event, on);
|
|
107
92
|
return this;
|
|
@@ -124,10 +109,8 @@ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.rem
|
|
|
124
109
|
}
|
|
125
110
|
|
|
126
111
|
var cb;
|
|
127
|
-
|
|
128
112
|
for (var i = 0; i < callbacks.length; i++) {
|
|
129
113
|
cb = callbacks[i];
|
|
130
|
-
|
|
131
114
|
if (cb === fn || cb.fn === fn) {
|
|
132
115
|
callbacks.splice(i, 1);
|
|
133
116
|
break;
|
|
@@ -137,27 +120,22 @@ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.rem
|
|
|
137
120
|
if (callbacks.length === 0) {
|
|
138
121
|
delete this._callbacks['$' + event];
|
|
139
122
|
}
|
|
140
|
-
|
|
141
123
|
return this;
|
|
142
124
|
};
|
|
143
125
|
|
|
144
126
|
Emitter.prototype.emit = function (event) {
|
|
145
127
|
this._callbacks = this._callbacks || {};
|
|
146
128
|
var args = new Array(arguments.length - 1),
|
|
147
|
-
|
|
148
|
-
|
|
129
|
+
callbacks = this._callbacks['$' + event];
|
|
149
130
|
for (var i = 1; i < arguments.length; i++) {
|
|
150
131
|
args[i - 1] = arguments[i];
|
|
151
132
|
}
|
|
152
|
-
|
|
153
133
|
if (callbacks) {
|
|
154
134
|
callbacks = callbacks.slice(0);
|
|
155
|
-
|
|
156
135
|
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
|
157
136
|
callbacks[i].apply(this, args);
|
|
158
137
|
}
|
|
159
138
|
}
|
|
160
|
-
|
|
161
139
|
return this;
|
|
162
140
|
};
|
|
163
141
|
|
|
@@ -179,7 +157,6 @@ var LIMIT_REPLACE_NODE = '[...]';
|
|
|
179
157
|
var CIRCULAR_REPLACE_NODE = '[Circular]';
|
|
180
158
|
var arr = [];
|
|
181
159
|
var replacerStack = [];
|
|
182
|
-
|
|
183
160
|
function defaultOptions() {
|
|
184
161
|
return {
|
|
185
162
|
depthLimit: Number.MAX_SAFE_INTEGER,
|
|
@@ -191,10 +168,8 @@ function stringify(obj, replacer, spacer, options) {
|
|
|
191
168
|
if (typeof options === 'undefined') {
|
|
192
169
|
options = defaultOptions();
|
|
193
170
|
}
|
|
194
|
-
|
|
195
171
|
decirc(obj, '', 0, [], undefined, 0, options);
|
|
196
172
|
var res;
|
|
197
|
-
|
|
198
173
|
try {
|
|
199
174
|
if (replacerStack.length === 0) {
|
|
200
175
|
res = JSON.stringify(obj, replacer, spacer);
|
|
@@ -206,7 +181,6 @@ function stringify(obj, replacer, spacer, options) {
|
|
|
206
181
|
} finally {
|
|
207
182
|
while (arr.length !== 0) {
|
|
208
183
|
var part = arr.pop();
|
|
209
|
-
|
|
210
184
|
if (part.length === 4) {
|
|
211
185
|
Object.defineProperty(part[0], part[1], part[3]);
|
|
212
186
|
} else {
|
|
@@ -214,13 +188,10 @@ function stringify(obj, replacer, spacer, options) {
|
|
|
214
188
|
}
|
|
215
189
|
}
|
|
216
190
|
}
|
|
217
|
-
|
|
218
191
|
return res;
|
|
219
192
|
}
|
|
220
|
-
|
|
221
193
|
function setReplace(replace, val, k, parent) {
|
|
222
194
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
|
|
223
|
-
|
|
224
195
|
if (propertyDescriptor.get !== undefined) {
|
|
225
196
|
if (propertyDescriptor.configurable) {
|
|
226
197
|
Object.defineProperty(parent, k, {
|
|
@@ -235,11 +206,9 @@ function setReplace(replace, val, k, parent) {
|
|
|
235
206
|
arr.push([parent, k, val]);
|
|
236
207
|
}
|
|
237
208
|
}
|
|
238
|
-
|
|
239
209
|
function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
240
210
|
depth += 1;
|
|
241
211
|
var i;
|
|
242
|
-
|
|
243
212
|
if (typeof val === 'object' && val !== null) {
|
|
244
213
|
for (i = 0; i < stack.length; i++) {
|
|
245
214
|
if (stack[i] === val) {
|
|
@@ -247,32 +216,26 @@ function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
247
216
|
return;
|
|
248
217
|
}
|
|
249
218
|
}
|
|
250
|
-
|
|
251
219
|
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
252
220
|
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
253
221
|
return;
|
|
254
222
|
}
|
|
255
|
-
|
|
256
223
|
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
257
224
|
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
258
225
|
return;
|
|
259
226
|
}
|
|
260
|
-
|
|
261
227
|
stack.push(val);
|
|
262
|
-
|
|
263
228
|
if (Array.isArray(val)) {
|
|
264
229
|
for (i = 0; i < val.length; i++) {
|
|
265
230
|
decirc(val[i], i, i, stack, val, depth, options);
|
|
266
231
|
}
|
|
267
232
|
} else {
|
|
268
233
|
var keys = Object.keys(val);
|
|
269
|
-
|
|
270
234
|
for (i = 0; i < keys.length; i++) {
|
|
271
235
|
var key = keys[i];
|
|
272
236
|
decirc(val[key], key, i, stack, val, depth, options);
|
|
273
237
|
}
|
|
274
238
|
}
|
|
275
|
-
|
|
276
239
|
stack.pop();
|
|
277
240
|
}
|
|
278
241
|
}
|
|
@@ -281,22 +244,17 @@ function compareFunction(a, b) {
|
|
|
281
244
|
if (a < b) {
|
|
282
245
|
return -1;
|
|
283
246
|
}
|
|
284
|
-
|
|
285
247
|
if (a > b) {
|
|
286
248
|
return 1;
|
|
287
249
|
}
|
|
288
|
-
|
|
289
250
|
return 0;
|
|
290
251
|
}
|
|
291
|
-
|
|
292
252
|
function deterministicStringify(obj, replacer, spacer, options) {
|
|
293
253
|
if (typeof options === 'undefined') {
|
|
294
254
|
options = defaultOptions();
|
|
295
255
|
}
|
|
296
|
-
|
|
297
256
|
var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj;
|
|
298
257
|
var res;
|
|
299
|
-
|
|
300
258
|
try {
|
|
301
259
|
if (replacerStack.length === 0) {
|
|
302
260
|
res = JSON.stringify(tmp, replacer, spacer);
|
|
@@ -308,7 +266,6 @@ function deterministicStringify(obj, replacer, spacer, options) {
|
|
|
308
266
|
} finally {
|
|
309
267
|
while (arr.length !== 0) {
|
|
310
268
|
var part = arr.pop();
|
|
311
|
-
|
|
312
269
|
if (part.length === 4) {
|
|
313
270
|
Object.defineProperty(part[0], part[1], part[3]);
|
|
314
271
|
} else {
|
|
@@ -316,14 +273,11 @@ function deterministicStringify(obj, replacer, spacer, options) {
|
|
|
316
273
|
}
|
|
317
274
|
}
|
|
318
275
|
}
|
|
319
|
-
|
|
320
276
|
return res;
|
|
321
277
|
}
|
|
322
|
-
|
|
323
278
|
function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
324
279
|
depth += 1;
|
|
325
280
|
var i;
|
|
326
|
-
|
|
327
281
|
if (typeof val === 'object' && val !== null) {
|
|
328
282
|
for (i = 0; i < stack.length; i++) {
|
|
329
283
|
if (stack[i] === val) {
|
|
@@ -331,7 +285,6 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
331
285
|
return;
|
|
332
286
|
}
|
|
333
287
|
}
|
|
334
|
-
|
|
335
288
|
try {
|
|
336
289
|
if (typeof val.toJSON === 'function') {
|
|
337
290
|
return;
|
|
@@ -339,19 +292,15 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
339
292
|
} catch (_) {
|
|
340
293
|
return;
|
|
341
294
|
}
|
|
342
|
-
|
|
343
295
|
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
344
296
|
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
345
297
|
return;
|
|
346
298
|
}
|
|
347
|
-
|
|
348
299
|
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
349
300
|
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
350
301
|
return;
|
|
351
302
|
}
|
|
352
|
-
|
|
353
303
|
stack.push(val);
|
|
354
|
-
|
|
355
304
|
if (Array.isArray(val)) {
|
|
356
305
|
for (i = 0; i < val.length; i++) {
|
|
357
306
|
deterministicDecirc(val[i], i, i, stack, val, depth, options);
|
|
@@ -359,13 +308,11 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
359
308
|
} else {
|
|
360
309
|
var tmp = {};
|
|
361
310
|
var keys = Object.keys(val).sort(compareFunction);
|
|
362
|
-
|
|
363
311
|
for (i = 0; i < keys.length; i++) {
|
|
364
312
|
var key = keys[i];
|
|
365
313
|
deterministicDecirc(val[key], key, i, stack, val, depth, options);
|
|
366
314
|
tmp[key] = val[key];
|
|
367
315
|
}
|
|
368
|
-
|
|
369
316
|
if (typeof parent !== 'undefined') {
|
|
370
317
|
arr.push([parent, k, val]);
|
|
371
318
|
parent[k] = tmp;
|
|
@@ -373,7 +320,6 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
373
320
|
return tmp;
|
|
374
321
|
}
|
|
375
322
|
}
|
|
376
|
-
|
|
377
323
|
stack.pop();
|
|
378
324
|
}
|
|
379
325
|
}
|
|
@@ -386,7 +332,6 @@ function replaceGetterValues(replacer) {
|
|
|
386
332
|
if (replacerStack.length > 0) {
|
|
387
333
|
for (var i = 0; i < replacerStack.length; i++) {
|
|
388
334
|
var part = replacerStack[i];
|
|
389
|
-
|
|
390
335
|
if (part[1] === key && part[0] === val) {
|
|
391
336
|
val = part[2];
|
|
392
337
|
replacerStack.splice(i, 1);
|
|
@@ -394,7 +339,6 @@ function replaceGetterValues(replacer) {
|
|
|
394
339
|
}
|
|
395
340
|
}
|
|
396
341
|
}
|
|
397
|
-
|
|
398
342
|
return replacer.call(this, key, val);
|
|
399
343
|
};
|
|
400
344
|
}
|
|
@@ -406,48 +350,36 @@ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
|
406
350
|
var slice = Array.prototype.slice;
|
|
407
351
|
var toStr = Object.prototype.toString;
|
|
408
352
|
var funcType = '[object Function]';
|
|
409
|
-
|
|
410
353
|
module.exports = function bind(that) {
|
|
411
354
|
var target = this;
|
|
412
|
-
|
|
413
355
|
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
|
|
414
356
|
throw new TypeError(ERROR_MESSAGE + target);
|
|
415
357
|
}
|
|
416
|
-
|
|
417
358
|
var args = slice.call(arguments, 1);
|
|
418
359
|
var bound;
|
|
419
|
-
|
|
420
360
|
var binder = function () {
|
|
421
361
|
if (this instanceof bound) {
|
|
422
362
|
var result = target.apply(this, args.concat(slice.call(arguments)));
|
|
423
|
-
|
|
424
363
|
if (Object(result) === result) {
|
|
425
364
|
return result;
|
|
426
365
|
}
|
|
427
|
-
|
|
428
366
|
return this;
|
|
429
367
|
} else {
|
|
430
368
|
return target.apply(that, args.concat(slice.call(arguments)));
|
|
431
369
|
}
|
|
432
370
|
};
|
|
433
|
-
|
|
434
371
|
var boundLength = Math.max(0, target.length - args.length);
|
|
435
372
|
var boundArgs = [];
|
|
436
|
-
|
|
437
373
|
for (var i = 0; i < boundLength; i++) {
|
|
438
374
|
boundArgs.push('$' + i);
|
|
439
375
|
}
|
|
440
|
-
|
|
441
376
|
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
442
|
-
|
|
443
377
|
if (target.prototype) {
|
|
444
378
|
var Empty = function Empty() {};
|
|
445
|
-
|
|
446
379
|
Empty.prototype = target.prototype;
|
|
447
380
|
bound.prototype = new Empty();
|
|
448
381
|
Empty.prototype = null;
|
|
449
382
|
}
|
|
450
|
-
|
|
451
383
|
return bound;
|
|
452
384
|
};
|
|
453
385
|
|
|
@@ -455,7 +387,6 @@ module.exports = function bind(that) {
|
|
|
455
387
|
'use strict';
|
|
456
388
|
|
|
457
389
|
var implementation = require('./implementation');
|
|
458
|
-
|
|
459
390
|
module.exports = Function.prototype.bind || implementation;
|
|
460
391
|
|
|
461
392
|
},{"./implementation":6}],8:[function(require,module,exports){
|
|
@@ -471,9 +402,7 @@ var getEvalledConstructor = function (expressionSyntax) {
|
|
|
471
402
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
472
403
|
} catch (e) {}
|
|
473
404
|
};
|
|
474
|
-
|
|
475
405
|
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
476
|
-
|
|
477
406
|
if ($gOPD) {
|
|
478
407
|
try {
|
|
479
408
|
$gOPD({}, '');
|
|
@@ -485,7 +414,6 @@ if ($gOPD) {
|
|
|
485
414
|
var throwTypeError = function () {
|
|
486
415
|
throw new $TypeError();
|
|
487
416
|
};
|
|
488
|
-
|
|
489
417
|
var ThrowTypeError = $gOPD ? function () {
|
|
490
418
|
try {
|
|
491
419
|
arguments.callee;
|
|
@@ -498,9 +426,7 @@ var ThrowTypeError = $gOPD ? function () {
|
|
|
498
426
|
}
|
|
499
427
|
}
|
|
500
428
|
}() : throwTypeError;
|
|
501
|
-
|
|
502
429
|
var hasSymbols = require('has-symbols')();
|
|
503
|
-
|
|
504
430
|
var getProto = Object.getPrototypeOf || function (x) {
|
|
505
431
|
return x.__proto__;
|
|
506
432
|
};
|
|
@@ -573,10 +499,8 @@ var INTRINSICS = {
|
|
|
573
499
|
'%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
|
|
574
500
|
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
|
|
575
501
|
};
|
|
576
|
-
|
|
577
502
|
var doEval = function doEval(name) {
|
|
578
503
|
var value;
|
|
579
|
-
|
|
580
504
|
if (name === '%AsyncFunction%') {
|
|
581
505
|
value = getEvalledConstructor('async function () {}');
|
|
582
506
|
} else if (name === '%GeneratorFunction%') {
|
|
@@ -585,22 +509,18 @@ var doEval = function doEval(name) {
|
|
|
585
509
|
value = getEvalledConstructor('async function* () {}');
|
|
586
510
|
} else if (name === '%AsyncGenerator%') {
|
|
587
511
|
var fn = doEval('%AsyncGeneratorFunction%');
|
|
588
|
-
|
|
589
512
|
if (fn) {
|
|
590
513
|
value = fn.prototype;
|
|
591
514
|
}
|
|
592
515
|
} else if (name === '%AsyncIteratorPrototype%') {
|
|
593
516
|
var gen = doEval('%AsyncGenerator%');
|
|
594
|
-
|
|
595
517
|
if (gen) {
|
|
596
518
|
value = getProto(gen.prototype);
|
|
597
519
|
}
|
|
598
520
|
}
|
|
599
|
-
|
|
600
521
|
INTRINSICS[name] = value;
|
|
601
522
|
return value;
|
|
602
523
|
};
|
|
603
|
-
|
|
604
524
|
var LEGACY_ALIASES = {
|
|
605
525
|
'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
|
606
526
|
'%ArrayPrototype%': ['Array', 'prototype'],
|
|
@@ -654,29 +574,24 @@ var LEGACY_ALIASES = {
|
|
|
654
574
|
'%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
|
655
575
|
'%WeakSetPrototype%': ['WeakSet', 'prototype']
|
|
656
576
|
};
|
|
657
|
-
|
|
658
577
|
var bind = require('function-bind');
|
|
659
|
-
|
|
660
578
|
var hasOwn = require('has');
|
|
661
|
-
|
|
662
579
|
var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
663
580
|
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
664
581
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
665
582
|
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
666
583
|
var $exec = bind.call(Function.call, RegExp.prototype.exec);
|
|
584
|
+
|
|
667
585
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
668
586
|
var reEscapeChar = /\\(\\)?/g;
|
|
669
|
-
|
|
670
587
|
var stringToPath = function stringToPath(string) {
|
|
671
588
|
var first = $strSlice(string, 0, 1);
|
|
672
589
|
var last = $strSlice(string, -1);
|
|
673
|
-
|
|
674
590
|
if (first === '%' && last !== '%') {
|
|
675
591
|
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
676
592
|
} else if (last === '%' && first !== '%') {
|
|
677
593
|
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
678
594
|
}
|
|
679
|
-
|
|
680
595
|
var result = [];
|
|
681
596
|
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
682
597
|
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
|
@@ -687,46 +602,36 @@ var stringToPath = function stringToPath(string) {
|
|
|
687
602
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
688
603
|
var intrinsicName = name;
|
|
689
604
|
var alias;
|
|
690
|
-
|
|
691
605
|
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
692
606
|
alias = LEGACY_ALIASES[intrinsicName];
|
|
693
607
|
intrinsicName = '%' + alias[0] + '%';
|
|
694
608
|
}
|
|
695
|
-
|
|
696
609
|
if (hasOwn(INTRINSICS, intrinsicName)) {
|
|
697
610
|
var value = INTRINSICS[intrinsicName];
|
|
698
|
-
|
|
699
611
|
if (value === needsEval) {
|
|
700
612
|
value = doEval(intrinsicName);
|
|
701
613
|
}
|
|
702
|
-
|
|
703
614
|
if (typeof value === 'undefined' && !allowMissing) {
|
|
704
615
|
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
705
616
|
}
|
|
706
|
-
|
|
707
617
|
return {
|
|
708
618
|
alias: alias,
|
|
709
619
|
name: intrinsicName,
|
|
710
620
|
value: value
|
|
711
621
|
};
|
|
712
622
|
}
|
|
713
|
-
|
|
714
623
|
throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
715
624
|
};
|
|
716
|
-
|
|
717
625
|
module.exports = function GetIntrinsic(name, allowMissing) {
|
|
718
626
|
if (typeof name !== 'string' || name.length === 0) {
|
|
719
627
|
throw new $TypeError('intrinsic name must be a non-empty string');
|
|
720
628
|
}
|
|
721
|
-
|
|
722
629
|
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
723
630
|
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
724
631
|
}
|
|
725
|
-
|
|
726
632
|
if ($exec(/^%?[^%]*%?$/, name) === null) {
|
|
727
633
|
throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
728
634
|
}
|
|
729
|
-
|
|
730
635
|
var parts = stringToPath(name);
|
|
731
636
|
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
732
637
|
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
@@ -734,28 +639,22 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
734
639
|
var value = intrinsic.value;
|
|
735
640
|
var skipFurtherCaching = false;
|
|
736
641
|
var alias = intrinsic.alias;
|
|
737
|
-
|
|
738
642
|
if (alias) {
|
|
739
643
|
intrinsicBaseName = alias[0];
|
|
740
644
|
$spliceApply(parts, $concat([0, 1], alias));
|
|
741
645
|
}
|
|
742
|
-
|
|
743
646
|
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
|
744
647
|
var part = parts[i];
|
|
745
648
|
var first = $strSlice(part, 0, 1);
|
|
746
649
|
var last = $strSlice(part, -1);
|
|
747
|
-
|
|
748
650
|
if ((first === '"' || first === "'" || first === '`' || last === '"' || last === "'" || last === '`') && first !== last) {
|
|
749
651
|
throw new $SyntaxError('property names with quotes must have matching quotes');
|
|
750
652
|
}
|
|
751
|
-
|
|
752
653
|
if (part === 'constructor' || !isOwn) {
|
|
753
654
|
skipFurtherCaching = true;
|
|
754
655
|
}
|
|
755
|
-
|
|
756
656
|
intrinsicBaseName += '.' + part;
|
|
757
657
|
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
758
|
-
|
|
759
658
|
if (hasOwn(INTRINSICS, intrinsicRealName)) {
|
|
760
659
|
value = INTRINSICS[intrinsicRealName];
|
|
761
660
|
} else if (value != null) {
|
|
@@ -763,10 +662,8 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
763
662
|
if (!allowMissing) {
|
|
764
663
|
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
765
664
|
}
|
|
766
|
-
|
|
767
665
|
return void undefined;
|
|
768
666
|
}
|
|
769
|
-
|
|
770
667
|
if ($gOPD && i + 1 >= parts.length) {
|
|
771
668
|
var desc = $gOPD(value, part);
|
|
772
669
|
isOwn = !!desc;
|
|
@@ -780,13 +677,11 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
780
677
|
isOwn = hasOwn(value, part);
|
|
781
678
|
value = value[part];
|
|
782
679
|
}
|
|
783
|
-
|
|
784
680
|
if (isOwn && !skipFurtherCaching) {
|
|
785
681
|
INTRINSICS[intrinsicRealName] = value;
|
|
786
682
|
}
|
|
787
683
|
}
|
|
788
684
|
}
|
|
789
|
-
|
|
790
685
|
return value;
|
|
791
686
|
};
|
|
792
687
|
|
|
@@ -794,26 +689,20 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
794
689
|
'use strict';
|
|
795
690
|
|
|
796
691
|
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
797
|
-
|
|
798
692
|
var hasSymbolSham = require('./shams');
|
|
799
|
-
|
|
800
693
|
module.exports = function hasNativeSymbols() {
|
|
801
694
|
if (typeof origSymbol !== 'function') {
|
|
802
695
|
return false;
|
|
803
696
|
}
|
|
804
|
-
|
|
805
697
|
if (typeof Symbol !== 'function') {
|
|
806
698
|
return false;
|
|
807
699
|
}
|
|
808
|
-
|
|
809
700
|
if (typeof origSymbol('foo') !== 'symbol') {
|
|
810
701
|
return false;
|
|
811
702
|
}
|
|
812
|
-
|
|
813
703
|
if (typeof Symbol('bar') !== 'symbol') {
|
|
814
704
|
return false;
|
|
815
705
|
}
|
|
816
|
-
|
|
817
706
|
return hasSymbolSham();
|
|
818
707
|
};
|
|
819
708
|
|
|
@@ -824,60 +713,46 @@ module.exports = function hasSymbols() {
|
|
|
824
713
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
825
714
|
return false;
|
|
826
715
|
}
|
|
827
|
-
|
|
828
716
|
if (typeof Symbol.iterator === 'symbol') {
|
|
829
717
|
return true;
|
|
830
718
|
}
|
|
831
|
-
|
|
832
719
|
var obj = {};
|
|
833
720
|
var sym = Symbol('test');
|
|
834
721
|
var symObj = Object(sym);
|
|
835
|
-
|
|
836
722
|
if (typeof sym === 'string') {
|
|
837
723
|
return false;
|
|
838
724
|
}
|
|
839
|
-
|
|
840
725
|
if (Object.prototype.toString.call(sym) !== '[object Symbol]') {
|
|
841
726
|
return false;
|
|
842
727
|
}
|
|
843
|
-
|
|
844
728
|
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') {
|
|
845
729
|
return false;
|
|
846
730
|
}
|
|
847
731
|
|
|
848
732
|
var symVal = 42;
|
|
849
733
|
obj[sym] = symVal;
|
|
850
|
-
|
|
851
734
|
for (sym in obj) {
|
|
852
735
|
return false;
|
|
853
736
|
}
|
|
854
|
-
|
|
855
737
|
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) {
|
|
856
738
|
return false;
|
|
857
739
|
}
|
|
858
|
-
|
|
859
740
|
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) {
|
|
860
741
|
return false;
|
|
861
742
|
}
|
|
862
|
-
|
|
863
743
|
var syms = Object.getOwnPropertySymbols(obj);
|
|
864
|
-
|
|
865
744
|
if (syms.length !== 1 || syms[0] !== sym) {
|
|
866
745
|
return false;
|
|
867
746
|
}
|
|
868
|
-
|
|
869
747
|
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
|
|
870
748
|
return false;
|
|
871
749
|
}
|
|
872
|
-
|
|
873
750
|
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
874
751
|
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
875
|
-
|
|
876
752
|
if (descriptor.value !== symVal || descriptor.enumerable !== true) {
|
|
877
753
|
return false;
|
|
878
754
|
}
|
|
879
755
|
}
|
|
880
|
-
|
|
881
756
|
return true;
|
|
882
757
|
};
|
|
883
758
|
|
|
@@ -885,7 +760,6 @@ module.exports = function hasSymbols() {
|
|
|
885
760
|
'use strict';
|
|
886
761
|
|
|
887
762
|
var bind = require('function-bind');
|
|
888
|
-
|
|
889
763
|
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
890
764
|
|
|
891
765
|
},{"function-bind":7}],12:[function(require,module,exports){
|
|
@@ -925,185 +799,137 @@ var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
|
925
799
|
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
|
|
926
800
|
return O.__proto__;
|
|
927
801
|
} : null);
|
|
928
|
-
|
|
929
802
|
function addNumericSeparator(num, str) {
|
|
930
803
|
if (num === Infinity || num === -Infinity || num !== num || num && num > -1000 && num < 1000 || $test.call(/e/, str)) {
|
|
931
804
|
return str;
|
|
932
805
|
}
|
|
933
|
-
|
|
934
806
|
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
|
|
935
|
-
|
|
936
807
|
if (typeof num === 'number') {
|
|
937
808
|
var int = num < 0 ? -$floor(-num) : $floor(num);
|
|
938
|
-
|
|
939
809
|
if (int !== num) {
|
|
940
810
|
var intStr = String(int);
|
|
941
811
|
var dec = $slice.call(str, intStr.length + 1);
|
|
942
812
|
return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
|
|
943
813
|
}
|
|
944
814
|
}
|
|
945
|
-
|
|
946
815
|
return $replace.call(str, sepRegex, '$&_');
|
|
947
816
|
}
|
|
948
|
-
|
|
949
817
|
var utilInspect = require('./util.inspect');
|
|
950
|
-
|
|
951
818
|
var inspectCustom = utilInspect.custom;
|
|
952
819
|
var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
|
|
953
|
-
|
|
954
820
|
module.exports = function inspect_(obj, options, depth, seen) {
|
|
955
821
|
var opts = options || {};
|
|
956
|
-
|
|
957
822
|
if (has(opts, 'quoteStyle') && opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double') {
|
|
958
823
|
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
|
959
824
|
}
|
|
960
|
-
|
|
961
825
|
if (has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number' ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
|
|
962
826
|
throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
|
|
963
827
|
}
|
|
964
|
-
|
|
965
828
|
var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
|
|
966
|
-
|
|
967
829
|
if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
|
|
968
830
|
throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
|
|
969
831
|
}
|
|
970
|
-
|
|
971
832
|
if (has(opts, 'indent') && opts.indent !== null && opts.indent !== '\t' && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
|
|
972
833
|
throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
|
|
973
834
|
}
|
|
974
|
-
|
|
975
835
|
if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
|
|
976
836
|
throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
|
|
977
837
|
}
|
|
978
|
-
|
|
979
838
|
var numericSeparator = opts.numericSeparator;
|
|
980
|
-
|
|
981
839
|
if (typeof obj === 'undefined') {
|
|
982
840
|
return 'undefined';
|
|
983
841
|
}
|
|
984
|
-
|
|
985
842
|
if (obj === null) {
|
|
986
843
|
return 'null';
|
|
987
844
|
}
|
|
988
|
-
|
|
989
845
|
if (typeof obj === 'boolean') {
|
|
990
846
|
return obj ? 'true' : 'false';
|
|
991
847
|
}
|
|
992
|
-
|
|
993
848
|
if (typeof obj === 'string') {
|
|
994
849
|
return inspectString(obj, opts);
|
|
995
850
|
}
|
|
996
|
-
|
|
997
851
|
if (typeof obj === 'number') {
|
|
998
852
|
if (obj === 0) {
|
|
999
853
|
return Infinity / obj > 0 ? '0' : '-0';
|
|
1000
854
|
}
|
|
1001
|
-
|
|
1002
855
|
var str = String(obj);
|
|
1003
856
|
return numericSeparator ? addNumericSeparator(obj, str) : str;
|
|
1004
857
|
}
|
|
1005
|
-
|
|
1006
858
|
if (typeof obj === 'bigint') {
|
|
1007
859
|
var bigIntStr = String(obj) + 'n';
|
|
1008
860
|
return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
|
|
1009
861
|
}
|
|
1010
|
-
|
|
1011
862
|
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
|
|
1012
|
-
|
|
1013
863
|
if (typeof depth === 'undefined') {
|
|
1014
864
|
depth = 0;
|
|
1015
865
|
}
|
|
1016
|
-
|
|
1017
866
|
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
|
1018
867
|
return isArray(obj) ? '[Array]' : '[Object]';
|
|
1019
868
|
}
|
|
1020
|
-
|
|
1021
869
|
var indent = getIndent(opts, depth);
|
|
1022
|
-
|
|
1023
870
|
if (typeof seen === 'undefined') {
|
|
1024
871
|
seen = [];
|
|
1025
872
|
} else if (indexOf(seen, obj) >= 0) {
|
|
1026
873
|
return '[Circular]';
|
|
1027
874
|
}
|
|
1028
|
-
|
|
1029
875
|
function inspect(value, from, noIndent) {
|
|
1030
876
|
if (from) {
|
|
1031
877
|
seen = $arrSlice.call(seen);
|
|
1032
878
|
seen.push(from);
|
|
1033
879
|
}
|
|
1034
|
-
|
|
1035
880
|
if (noIndent) {
|
|
1036
881
|
var newOpts = {
|
|
1037
882
|
depth: opts.depth
|
|
1038
883
|
};
|
|
1039
|
-
|
|
1040
884
|
if (has(opts, 'quoteStyle')) {
|
|
1041
885
|
newOpts.quoteStyle = opts.quoteStyle;
|
|
1042
886
|
}
|
|
1043
|
-
|
|
1044
887
|
return inspect_(value, newOpts, depth + 1, seen);
|
|
1045
888
|
}
|
|
1046
|
-
|
|
1047
889
|
return inspect_(value, opts, depth + 1, seen);
|
|
1048
890
|
}
|
|
1049
|
-
|
|
1050
891
|
if (typeof obj === 'function' && !isRegExp(obj)) {
|
|
1051
892
|
var name = nameOf(obj);
|
|
1052
893
|
var keys = arrObjKeys(obj, inspect);
|
|
1053
894
|
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
|
|
1054
895
|
}
|
|
1055
|
-
|
|
1056
896
|
if (isSymbol(obj)) {
|
|
1057
897
|
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
|
1058
898
|
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
|
1059
899
|
}
|
|
1060
|
-
|
|
1061
900
|
if (isElement(obj)) {
|
|
1062
901
|
var s = '<' + $toLowerCase.call(String(obj.nodeName));
|
|
1063
902
|
var attrs = obj.attributes || [];
|
|
1064
|
-
|
|
1065
903
|
for (var i = 0; i < attrs.length; i++) {
|
|
1066
904
|
s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
|
|
1067
905
|
}
|
|
1068
|
-
|
|
1069
906
|
s += '>';
|
|
1070
|
-
|
|
1071
907
|
if (obj.childNodes && obj.childNodes.length) {
|
|
1072
908
|
s += '...';
|
|
1073
909
|
}
|
|
1074
|
-
|
|
1075
910
|
s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
|
|
1076
911
|
return s;
|
|
1077
912
|
}
|
|
1078
|
-
|
|
1079
913
|
if (isArray(obj)) {
|
|
1080
914
|
if (obj.length === 0) {
|
|
1081
915
|
return '[]';
|
|
1082
916
|
}
|
|
1083
|
-
|
|
1084
917
|
var xs = arrObjKeys(obj, inspect);
|
|
1085
|
-
|
|
1086
918
|
if (indent && !singleLineValues(xs)) {
|
|
1087
919
|
return '[' + indentedJoin(xs, indent) + ']';
|
|
1088
920
|
}
|
|
1089
|
-
|
|
1090
921
|
return '[ ' + $join.call(xs, ', ') + ' ]';
|
|
1091
922
|
}
|
|
1092
|
-
|
|
1093
923
|
if (isError(obj)) {
|
|
1094
924
|
var parts = arrObjKeys(obj, inspect);
|
|
1095
|
-
|
|
1096
925
|
if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
|
|
1097
926
|
return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
|
|
1098
927
|
}
|
|
1099
|
-
|
|
1100
928
|
if (parts.length === 0) {
|
|
1101
929
|
return '[' + String(obj) + ']';
|
|
1102
930
|
}
|
|
1103
|
-
|
|
1104
931
|
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
|
1105
932
|
}
|
|
1106
|
-
|
|
1107
933
|
if (typeof obj === 'object' && customInspect) {
|
|
1108
934
|
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
|
|
1109
935
|
return utilInspect(obj, {
|
|
@@ -1113,7 +939,6 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1113
939
|
return obj.inspect();
|
|
1114
940
|
}
|
|
1115
941
|
}
|
|
1116
|
-
|
|
1117
942
|
if (isMap(obj)) {
|
|
1118
943
|
var mapParts = [];
|
|
1119
944
|
mapForEach.call(obj, function (value, key) {
|
|
@@ -1121,7 +946,6 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1121
946
|
});
|
|
1122
947
|
return collectionOf('Map', mapSize.call(obj), mapParts, indent);
|
|
1123
948
|
}
|
|
1124
|
-
|
|
1125
949
|
if (isSet(obj)) {
|
|
1126
950
|
var setParts = [];
|
|
1127
951
|
setForEach.call(obj, function (value) {
|
|
@@ -1129,35 +953,27 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1129
953
|
});
|
|
1130
954
|
return collectionOf('Set', setSize.call(obj), setParts, indent);
|
|
1131
955
|
}
|
|
1132
|
-
|
|
1133
956
|
if (isWeakMap(obj)) {
|
|
1134
957
|
return weakCollectionOf('WeakMap');
|
|
1135
958
|
}
|
|
1136
|
-
|
|
1137
959
|
if (isWeakSet(obj)) {
|
|
1138
960
|
return weakCollectionOf('WeakSet');
|
|
1139
961
|
}
|
|
1140
|
-
|
|
1141
962
|
if (isWeakRef(obj)) {
|
|
1142
963
|
return weakCollectionOf('WeakRef');
|
|
1143
964
|
}
|
|
1144
|
-
|
|
1145
965
|
if (isNumber(obj)) {
|
|
1146
966
|
return markBoxed(inspect(Number(obj)));
|
|
1147
967
|
}
|
|
1148
|
-
|
|
1149
968
|
if (isBigInt(obj)) {
|
|
1150
969
|
return markBoxed(inspect(bigIntValueOf.call(obj)));
|
|
1151
970
|
}
|
|
1152
|
-
|
|
1153
971
|
if (isBoolean(obj)) {
|
|
1154
972
|
return markBoxed(booleanValueOf.call(obj));
|
|
1155
973
|
}
|
|
1156
|
-
|
|
1157
974
|
if (isString(obj)) {
|
|
1158
975
|
return markBoxed(inspect(String(obj)));
|
|
1159
976
|
}
|
|
1160
|
-
|
|
1161
977
|
if (!isDate(obj) && !isRegExp(obj)) {
|
|
1162
978
|
var ys = arrObjKeys(obj, inspect);
|
|
1163
979
|
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
@@ -1165,54 +981,41 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1165
981
|
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
|
|
1166
982
|
var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
|
|
1167
983
|
var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
|
|
1168
|
-
|
|
1169
984
|
if (ys.length === 0) {
|
|
1170
985
|
return tag + '{}';
|
|
1171
986
|
}
|
|
1172
|
-
|
|
1173
987
|
if (indent) {
|
|
1174
988
|
return tag + '{' + indentedJoin(ys, indent) + '}';
|
|
1175
989
|
}
|
|
1176
|
-
|
|
1177
990
|
return tag + '{ ' + $join.call(ys, ', ') + ' }';
|
|
1178
991
|
}
|
|
1179
|
-
|
|
1180
992
|
return String(obj);
|
|
1181
993
|
};
|
|
1182
|
-
|
|
1183
994
|
function wrapQuotes(s, defaultStyle, opts) {
|
|
1184
995
|
var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
|
|
1185
996
|
return quoteChar + s + quoteChar;
|
|
1186
997
|
}
|
|
1187
|
-
|
|
1188
998
|
function quote(s) {
|
|
1189
999
|
return $replace.call(String(s), /"/g, '"');
|
|
1190
1000
|
}
|
|
1191
|
-
|
|
1192
1001
|
function isArray(obj) {
|
|
1193
1002
|
return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1194
1003
|
}
|
|
1195
|
-
|
|
1196
1004
|
function isDate(obj) {
|
|
1197
1005
|
return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1198
1006
|
}
|
|
1199
|
-
|
|
1200
1007
|
function isRegExp(obj) {
|
|
1201
1008
|
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1202
1009
|
}
|
|
1203
|
-
|
|
1204
1010
|
function isError(obj) {
|
|
1205
1011
|
return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1206
1012
|
}
|
|
1207
|
-
|
|
1208
1013
|
function isString(obj) {
|
|
1209
1014
|
return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1210
1015
|
}
|
|
1211
|
-
|
|
1212
1016
|
function isNumber(obj) {
|
|
1213
1017
|
return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1214
1018
|
}
|
|
1215
|
-
|
|
1216
1019
|
function isBoolean(obj) {
|
|
1217
1020
|
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1218
1021
|
}
|
|
@@ -1221,192 +1024,146 @@ function isSymbol(obj) {
|
|
|
1221
1024
|
if (hasShammedSymbols) {
|
|
1222
1025
|
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
|
1223
1026
|
}
|
|
1224
|
-
|
|
1225
1027
|
if (typeof obj === 'symbol') {
|
|
1226
1028
|
return true;
|
|
1227
1029
|
}
|
|
1228
|
-
|
|
1229
1030
|
if (!obj || typeof obj !== 'object' || !symToString) {
|
|
1230
1031
|
return false;
|
|
1231
1032
|
}
|
|
1232
|
-
|
|
1233
1033
|
try {
|
|
1234
1034
|
symToString.call(obj);
|
|
1235
1035
|
return true;
|
|
1236
1036
|
} catch (e) {}
|
|
1237
|
-
|
|
1238
1037
|
return false;
|
|
1239
1038
|
}
|
|
1240
|
-
|
|
1241
1039
|
function isBigInt(obj) {
|
|
1242
1040
|
if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
|
|
1243
1041
|
return false;
|
|
1244
1042
|
}
|
|
1245
|
-
|
|
1246
1043
|
try {
|
|
1247
1044
|
bigIntValueOf.call(obj);
|
|
1248
1045
|
return true;
|
|
1249
1046
|
} catch (e) {}
|
|
1250
|
-
|
|
1251
1047
|
return false;
|
|
1252
1048
|
}
|
|
1253
|
-
|
|
1254
1049
|
var hasOwn = Object.prototype.hasOwnProperty || function (key) {
|
|
1255
1050
|
return key in this;
|
|
1256
1051
|
};
|
|
1257
|
-
|
|
1258
1052
|
function has(obj, key) {
|
|
1259
1053
|
return hasOwn.call(obj, key);
|
|
1260
1054
|
}
|
|
1261
|
-
|
|
1262
1055
|
function toStr(obj) {
|
|
1263
1056
|
return objectToString.call(obj);
|
|
1264
1057
|
}
|
|
1265
|
-
|
|
1266
1058
|
function nameOf(f) {
|
|
1267
1059
|
if (f.name) {
|
|
1268
1060
|
return f.name;
|
|
1269
1061
|
}
|
|
1270
|
-
|
|
1271
1062
|
var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
|
|
1272
|
-
|
|
1273
1063
|
if (m) {
|
|
1274
1064
|
return m[1];
|
|
1275
1065
|
}
|
|
1276
|
-
|
|
1277
1066
|
return null;
|
|
1278
1067
|
}
|
|
1279
|
-
|
|
1280
1068
|
function indexOf(xs, x) {
|
|
1281
1069
|
if (xs.indexOf) {
|
|
1282
1070
|
return xs.indexOf(x);
|
|
1283
1071
|
}
|
|
1284
|
-
|
|
1285
1072
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
1286
1073
|
if (xs[i] === x) {
|
|
1287
1074
|
return i;
|
|
1288
1075
|
}
|
|
1289
1076
|
}
|
|
1290
|
-
|
|
1291
1077
|
return -1;
|
|
1292
1078
|
}
|
|
1293
|
-
|
|
1294
1079
|
function isMap(x) {
|
|
1295
1080
|
if (!mapSize || !x || typeof x !== 'object') {
|
|
1296
1081
|
return false;
|
|
1297
1082
|
}
|
|
1298
|
-
|
|
1299
1083
|
try {
|
|
1300
1084
|
mapSize.call(x);
|
|
1301
|
-
|
|
1302
1085
|
try {
|
|
1303
1086
|
setSize.call(x);
|
|
1304
1087
|
} catch (s) {
|
|
1305
1088
|
return true;
|
|
1306
1089
|
}
|
|
1307
|
-
|
|
1308
1090
|
return x instanceof Map;
|
|
1309
1091
|
} catch (e) {}
|
|
1310
|
-
|
|
1311
1092
|
return false;
|
|
1312
1093
|
}
|
|
1313
|
-
|
|
1314
1094
|
function isWeakMap(x) {
|
|
1315
1095
|
if (!weakMapHas || !x || typeof x !== 'object') {
|
|
1316
1096
|
return false;
|
|
1317
1097
|
}
|
|
1318
|
-
|
|
1319
1098
|
try {
|
|
1320
1099
|
weakMapHas.call(x, weakMapHas);
|
|
1321
|
-
|
|
1322
1100
|
try {
|
|
1323
1101
|
weakSetHas.call(x, weakSetHas);
|
|
1324
1102
|
} catch (s) {
|
|
1325
1103
|
return true;
|
|
1326
1104
|
}
|
|
1327
|
-
|
|
1328
1105
|
return x instanceof WeakMap;
|
|
1329
1106
|
} catch (e) {}
|
|
1330
|
-
|
|
1331
1107
|
return false;
|
|
1332
1108
|
}
|
|
1333
|
-
|
|
1334
1109
|
function isWeakRef(x) {
|
|
1335
1110
|
if (!weakRefDeref || !x || typeof x !== 'object') {
|
|
1336
1111
|
return false;
|
|
1337
1112
|
}
|
|
1338
|
-
|
|
1339
1113
|
try {
|
|
1340
1114
|
weakRefDeref.call(x);
|
|
1341
1115
|
return true;
|
|
1342
1116
|
} catch (e) {}
|
|
1343
|
-
|
|
1344
1117
|
return false;
|
|
1345
1118
|
}
|
|
1346
|
-
|
|
1347
1119
|
function isSet(x) {
|
|
1348
1120
|
if (!setSize || !x || typeof x !== 'object') {
|
|
1349
1121
|
return false;
|
|
1350
1122
|
}
|
|
1351
|
-
|
|
1352
1123
|
try {
|
|
1353
1124
|
setSize.call(x);
|
|
1354
|
-
|
|
1355
1125
|
try {
|
|
1356
1126
|
mapSize.call(x);
|
|
1357
1127
|
} catch (m) {
|
|
1358
1128
|
return true;
|
|
1359
1129
|
}
|
|
1360
|
-
|
|
1361
1130
|
return x instanceof Set;
|
|
1362
1131
|
} catch (e) {}
|
|
1363
|
-
|
|
1364
1132
|
return false;
|
|
1365
1133
|
}
|
|
1366
|
-
|
|
1367
1134
|
function isWeakSet(x) {
|
|
1368
1135
|
if (!weakSetHas || !x || typeof x !== 'object') {
|
|
1369
1136
|
return false;
|
|
1370
1137
|
}
|
|
1371
|
-
|
|
1372
1138
|
try {
|
|
1373
1139
|
weakSetHas.call(x, weakSetHas);
|
|
1374
|
-
|
|
1375
1140
|
try {
|
|
1376
1141
|
weakMapHas.call(x, weakMapHas);
|
|
1377
1142
|
} catch (s) {
|
|
1378
1143
|
return true;
|
|
1379
1144
|
}
|
|
1380
|
-
|
|
1381
1145
|
return x instanceof WeakSet;
|
|
1382
1146
|
} catch (e) {}
|
|
1383
|
-
|
|
1384
1147
|
return false;
|
|
1385
1148
|
}
|
|
1386
|
-
|
|
1387
1149
|
function isElement(x) {
|
|
1388
1150
|
if (!x || typeof x !== 'object') {
|
|
1389
1151
|
return false;
|
|
1390
1152
|
}
|
|
1391
|
-
|
|
1392
1153
|
if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
|
|
1393
1154
|
return true;
|
|
1394
1155
|
}
|
|
1395
|
-
|
|
1396
1156
|
return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
|
|
1397
1157
|
}
|
|
1398
|
-
|
|
1399
1158
|
function inspectString(str, opts) {
|
|
1400
1159
|
if (str.length > opts.maxStringLength) {
|
|
1401
1160
|
var remaining = str.length - opts.maxStringLength;
|
|
1402
1161
|
var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
|
|
1403
1162
|
return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
|
|
1404
1163
|
}
|
|
1405
|
-
|
|
1406
1164
|
var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
|
|
1407
1165
|
return wrapQuotes(s, 'single', opts);
|
|
1408
1166
|
}
|
|
1409
|
-
|
|
1410
1167
|
function lowbyte(c) {
|
|
1411
1168
|
var n = c.charCodeAt(0);
|
|
1412
1169
|
var x = {
|
|
@@ -1416,40 +1173,31 @@ function lowbyte(c) {
|
|
|
1416
1173
|
12: 'f',
|
|
1417
1174
|
13: 'r'
|
|
1418
1175
|
}[n];
|
|
1419
|
-
|
|
1420
1176
|
if (x) {
|
|
1421
1177
|
return '\\' + x;
|
|
1422
1178
|
}
|
|
1423
|
-
|
|
1424
1179
|
return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
|
|
1425
1180
|
}
|
|
1426
|
-
|
|
1427
1181
|
function markBoxed(str) {
|
|
1428
1182
|
return 'Object(' + str + ')';
|
|
1429
1183
|
}
|
|
1430
|
-
|
|
1431
1184
|
function weakCollectionOf(type) {
|
|
1432
1185
|
return type + ' { ? }';
|
|
1433
1186
|
}
|
|
1434
|
-
|
|
1435
1187
|
function collectionOf(type, size, entries, indent) {
|
|
1436
1188
|
var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
|
|
1437
1189
|
return type + ' (' + size + ') {' + joinedEntries + '}';
|
|
1438
1190
|
}
|
|
1439
|
-
|
|
1440
1191
|
function singleLineValues(xs) {
|
|
1441
1192
|
for (var i = 0; i < xs.length; i++) {
|
|
1442
1193
|
if (indexOf(xs[i], '\n') >= 0) {
|
|
1443
1194
|
return false;
|
|
1444
1195
|
}
|
|
1445
1196
|
}
|
|
1446
|
-
|
|
1447
1197
|
return true;
|
|
1448
1198
|
}
|
|
1449
|
-
|
|
1450
1199
|
function getIndent(opts, depth) {
|
|
1451
1200
|
var baseIndent;
|
|
1452
|
-
|
|
1453
1201
|
if (opts.indent === '\t') {
|
|
1454
1202
|
baseIndent = '\t';
|
|
1455
1203
|
} else if (typeof opts.indent === 'number' && opts.indent > 0) {
|
|
@@ -1457,54 +1205,42 @@ function getIndent(opts, depth) {
|
|
|
1457
1205
|
} else {
|
|
1458
1206
|
return null;
|
|
1459
1207
|
}
|
|
1460
|
-
|
|
1461
1208
|
return {
|
|
1462
1209
|
base: baseIndent,
|
|
1463
1210
|
prev: $join.call(Array(depth + 1), baseIndent)
|
|
1464
1211
|
};
|
|
1465
1212
|
}
|
|
1466
|
-
|
|
1467
1213
|
function indentedJoin(xs, indent) {
|
|
1468
1214
|
if (xs.length === 0) {
|
|
1469
1215
|
return '';
|
|
1470
1216
|
}
|
|
1471
|
-
|
|
1472
1217
|
var lineJoiner = '\n' + indent.prev + indent.base;
|
|
1473
1218
|
return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
|
|
1474
1219
|
}
|
|
1475
|
-
|
|
1476
1220
|
function arrObjKeys(obj, inspect) {
|
|
1477
1221
|
var isArr = isArray(obj);
|
|
1478
1222
|
var xs = [];
|
|
1479
|
-
|
|
1480
1223
|
if (isArr) {
|
|
1481
1224
|
xs.length = obj.length;
|
|
1482
|
-
|
|
1483
1225
|
for (var i = 0; i < obj.length; i++) {
|
|
1484
1226
|
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
|
|
1485
1227
|
}
|
|
1486
1228
|
}
|
|
1487
|
-
|
|
1488
1229
|
var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
|
|
1489
1230
|
var symMap;
|
|
1490
|
-
|
|
1491
1231
|
if (hasShammedSymbols) {
|
|
1492
1232
|
symMap = {};
|
|
1493
|
-
|
|
1494
1233
|
for (var k = 0; k < syms.length; k++) {
|
|
1495
1234
|
symMap['$' + syms[k]] = syms[k];
|
|
1496
1235
|
}
|
|
1497
1236
|
}
|
|
1498
|
-
|
|
1499
1237
|
for (var key in obj) {
|
|
1500
1238
|
if (!has(obj, key)) {
|
|
1501
1239
|
continue;
|
|
1502
1240
|
}
|
|
1503
|
-
|
|
1504
1241
|
if (isArr && String(Number(key)) === key && key < obj.length) {
|
|
1505
1242
|
continue;
|
|
1506
1243
|
}
|
|
1507
|
-
|
|
1508
1244
|
if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
|
|
1509
1245
|
continue;
|
|
1510
1246
|
} else if ($test.call(/[^\w$]/, key)) {
|
|
@@ -1513,7 +1249,6 @@ function arrObjKeys(obj, inspect) {
|
|
|
1513
1249
|
xs.push(key + ': ' + inspect(obj[key], obj));
|
|
1514
1250
|
}
|
|
1515
1251
|
}
|
|
1516
|
-
|
|
1517
1252
|
if (typeof gOPS === 'function') {
|
|
1518
1253
|
for (var j = 0; j < syms.length; j++) {
|
|
1519
1254
|
if (isEnumerable.call(obj, syms[j])) {
|
|
@@ -1521,23 +1256,21 @@ function arrObjKeys(obj, inspect) {
|
|
|
1521
1256
|
}
|
|
1522
1257
|
}
|
|
1523
1258
|
}
|
|
1524
|
-
|
|
1525
1259
|
return xs;
|
|
1526
1260
|
}
|
|
1527
1261
|
|
|
1528
1262
|
},{"./util.inspect":1}],13:[function(require,module,exports){
|
|
1263
|
+
|
|
1529
1264
|
var process = module.exports = {};
|
|
1265
|
+
|
|
1530
1266
|
var cachedSetTimeout;
|
|
1531
1267
|
var cachedClearTimeout;
|
|
1532
|
-
|
|
1533
1268
|
function defaultSetTimout() {
|
|
1534
1269
|
throw new Error('setTimeout has not been defined');
|
|
1535
1270
|
}
|
|
1536
|
-
|
|
1537
1271
|
function defaultClearTimeout() {
|
|
1538
1272
|
throw new Error('clearTimeout has not been defined');
|
|
1539
1273
|
}
|
|
1540
|
-
|
|
1541
1274
|
(function () {
|
|
1542
1275
|
try {
|
|
1543
1276
|
if (typeof setTimeout === 'function') {
|
|
@@ -1548,7 +1281,6 @@ function defaultClearTimeout() {
|
|
|
1548
1281
|
} catch (e) {
|
|
1549
1282
|
cachedSetTimeout = defaultSetTimout;
|
|
1550
1283
|
}
|
|
1551
|
-
|
|
1552
1284
|
try {
|
|
1553
1285
|
if (typeof clearTimeout === 'function') {
|
|
1554
1286
|
cachedClearTimeout = clearTimeout;
|
|
@@ -1559,17 +1291,14 @@ function defaultClearTimeout() {
|
|
|
1559
1291
|
cachedClearTimeout = defaultClearTimeout;
|
|
1560
1292
|
}
|
|
1561
1293
|
})();
|
|
1562
|
-
|
|
1563
1294
|
function runTimeout(fun) {
|
|
1564
1295
|
if (cachedSetTimeout === setTimeout) {
|
|
1565
1296
|
return setTimeout(fun, 0);
|
|
1566
1297
|
}
|
|
1567
|
-
|
|
1568
1298
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
1569
1299
|
cachedSetTimeout = setTimeout;
|
|
1570
1300
|
return setTimeout(fun, 0);
|
|
1571
1301
|
}
|
|
1572
|
-
|
|
1573
1302
|
try {
|
|
1574
1303
|
return cachedSetTimeout(fun, 0);
|
|
1575
1304
|
} catch (e) {
|
|
@@ -1580,17 +1309,14 @@ function runTimeout(fun) {
|
|
|
1580
1309
|
}
|
|
1581
1310
|
}
|
|
1582
1311
|
}
|
|
1583
|
-
|
|
1584
1312
|
function runClearTimeout(marker) {
|
|
1585
1313
|
if (cachedClearTimeout === clearTimeout) {
|
|
1586
1314
|
return clearTimeout(marker);
|
|
1587
1315
|
}
|
|
1588
|
-
|
|
1589
1316
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
1590
1317
|
cachedClearTimeout = clearTimeout;
|
|
1591
1318
|
return clearTimeout(marker);
|
|
1592
1319
|
}
|
|
1593
|
-
|
|
1594
1320
|
try {
|
|
1595
1321
|
return cachedClearTimeout(marker);
|
|
1596
1322
|
} catch (e) {
|
|
@@ -1601,69 +1327,54 @@ function runClearTimeout(marker) {
|
|
|
1601
1327
|
}
|
|
1602
1328
|
}
|
|
1603
1329
|
}
|
|
1604
|
-
|
|
1605
1330
|
var queue = [];
|
|
1606
1331
|
var draining = false;
|
|
1607
1332
|
var currentQueue;
|
|
1608
1333
|
var queueIndex = -1;
|
|
1609
|
-
|
|
1610
1334
|
function cleanUpNextTick() {
|
|
1611
1335
|
if (!draining || !currentQueue) {
|
|
1612
1336
|
return;
|
|
1613
1337
|
}
|
|
1614
|
-
|
|
1615
1338
|
draining = false;
|
|
1616
|
-
|
|
1617
1339
|
if (currentQueue.length) {
|
|
1618
1340
|
queue = currentQueue.concat(queue);
|
|
1619
1341
|
} else {
|
|
1620
1342
|
queueIndex = -1;
|
|
1621
1343
|
}
|
|
1622
|
-
|
|
1623
1344
|
if (queue.length) {
|
|
1624
1345
|
drainQueue();
|
|
1625
1346
|
}
|
|
1626
1347
|
}
|
|
1627
|
-
|
|
1628
1348
|
function drainQueue() {
|
|
1629
1349
|
if (draining) {
|
|
1630
1350
|
return;
|
|
1631
1351
|
}
|
|
1632
|
-
|
|
1633
1352
|
var timeout = runTimeout(cleanUpNextTick);
|
|
1634
1353
|
draining = true;
|
|
1635
1354
|
var len = queue.length;
|
|
1636
|
-
|
|
1637
1355
|
while (len) {
|
|
1638
1356
|
currentQueue = queue;
|
|
1639
1357
|
queue = [];
|
|
1640
|
-
|
|
1641
1358
|
while (++queueIndex < len) {
|
|
1642
1359
|
if (currentQueue) {
|
|
1643
1360
|
currentQueue[queueIndex].run();
|
|
1644
1361
|
}
|
|
1645
1362
|
}
|
|
1646
|
-
|
|
1647
1363
|
queueIndex = -1;
|
|
1648
1364
|
len = queue.length;
|
|
1649
1365
|
}
|
|
1650
|
-
|
|
1651
1366
|
currentQueue = null;
|
|
1652
1367
|
draining = false;
|
|
1653
1368
|
runClearTimeout(timeout);
|
|
1654
1369
|
}
|
|
1655
|
-
|
|
1656
1370
|
process.nextTick = function (fun) {
|
|
1657
1371
|
var args = new Array(arguments.length - 1);
|
|
1658
|
-
|
|
1659
1372
|
if (arguments.length > 1) {
|
|
1660
1373
|
for (var i = 1; i < arguments.length; i++) {
|
|
1661
1374
|
args[i - 1] = arguments[i];
|
|
1662
1375
|
}
|
|
1663
1376
|
}
|
|
1664
|
-
|
|
1665
1377
|
queue.push(new Item(fun, args));
|
|
1666
|
-
|
|
1667
1378
|
if (queue.length === 1 && !draining) {
|
|
1668
1379
|
runTimeout(drainQueue);
|
|
1669
1380
|
}
|
|
@@ -1673,20 +1384,16 @@ function Item(fun, array) {
|
|
|
1673
1384
|
this.fun = fun;
|
|
1674
1385
|
this.array = array;
|
|
1675
1386
|
}
|
|
1676
|
-
|
|
1677
1387
|
Item.prototype.run = function () {
|
|
1678
1388
|
this.fun.apply(null, this.array);
|
|
1679
1389
|
};
|
|
1680
|
-
|
|
1681
1390
|
process.title = 'browser';
|
|
1682
1391
|
process.browser = true;
|
|
1683
1392
|
process.env = {};
|
|
1684
1393
|
process.argv = [];
|
|
1685
1394
|
process.version = '';
|
|
1686
1395
|
process.versions = {};
|
|
1687
|
-
|
|
1688
1396
|
function noop() {}
|
|
1689
|
-
|
|
1690
1397
|
process.on = noop;
|
|
1691
1398
|
process.addListener = noop;
|
|
1692
1399
|
process.once = noop;
|
|
@@ -1696,23 +1403,18 @@ process.removeAllListeners = noop;
|
|
|
1696
1403
|
process.emit = noop;
|
|
1697
1404
|
process.prependListener = noop;
|
|
1698
1405
|
process.prependOnceListener = noop;
|
|
1699
|
-
|
|
1700
1406
|
process.listeners = function (name) {
|
|
1701
1407
|
return [];
|
|
1702
1408
|
};
|
|
1703
|
-
|
|
1704
1409
|
process.binding = function (name) {
|
|
1705
1410
|
throw new Error('process.binding is not supported');
|
|
1706
1411
|
};
|
|
1707
|
-
|
|
1708
1412
|
process.cwd = function () {
|
|
1709
1413
|
return '/';
|
|
1710
1414
|
};
|
|
1711
|
-
|
|
1712
1415
|
process.chdir = function (dir) {
|
|
1713
1416
|
throw new Error('process.chdir is not supported');
|
|
1714
1417
|
};
|
|
1715
|
-
|
|
1716
1418
|
process.umask = function () {
|
|
1717
1419
|
return 0;
|
|
1718
1420
|
};
|
|
@@ -1744,11 +1446,8 @@ module.exports = {
|
|
|
1744
1446
|
'use strict';
|
|
1745
1447
|
|
|
1746
1448
|
var stringify = require('./stringify');
|
|
1747
|
-
|
|
1748
1449
|
var parse = require('./parse');
|
|
1749
|
-
|
|
1750
1450
|
var formats = require('./formats');
|
|
1751
|
-
|
|
1752
1451
|
module.exports = {
|
|
1753
1452
|
formats: formats,
|
|
1754
1453
|
parse: parse,
|
|
@@ -1759,7 +1458,6 @@ module.exports = {
|
|
|
1759
1458
|
'use strict';
|
|
1760
1459
|
|
|
1761
1460
|
var utils = require('./utils');
|
|
1762
|
-
|
|
1763
1461
|
var has = Object.prototype.hasOwnProperty;
|
|
1764
1462
|
var isArray = Array.isArray;
|
|
1765
1463
|
var defaults = {
|
|
@@ -1780,22 +1478,20 @@ var defaults = {
|
|
|
1780
1478
|
plainObjects: false,
|
|
1781
1479
|
strictNullHandling: false
|
|
1782
1480
|
};
|
|
1783
|
-
|
|
1784
1481
|
var interpretNumericEntities = function (str) {
|
|
1785
1482
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
1786
1483
|
return String.fromCharCode(parseInt(numberStr, 10));
|
|
1787
1484
|
});
|
|
1788
1485
|
};
|
|
1789
|
-
|
|
1790
1486
|
var parseArrayValue = function (val, options) {
|
|
1791
1487
|
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
1792
1488
|
return val.split(',');
|
|
1793
1489
|
}
|
|
1794
|
-
|
|
1795
1490
|
return val;
|
|
1796
1491
|
};
|
|
1797
1492
|
|
|
1798
1493
|
var isoSentinel = 'utf8=%26%2310003%3B';
|
|
1494
|
+
|
|
1799
1495
|
var charsetSentinel = 'utf8=%E2%9C%93';
|
|
1800
1496
|
|
|
1801
1497
|
var parseValues = function parseQueryStringValues(str, options) {
|
|
@@ -1806,7 +1502,6 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1806
1502
|
var skipIndex = -1;
|
|
1807
1503
|
var i;
|
|
1808
1504
|
var charset = options.charset;
|
|
1809
|
-
|
|
1810
1505
|
if (options.charsetSentinel) {
|
|
1811
1506
|
for (i = 0; i < parts.length; ++i) {
|
|
1812
1507
|
if (parts[i].indexOf('utf8=') === 0) {
|
|
@@ -1815,7 +1510,6 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1815
1510
|
} else if (parts[i] === isoSentinel) {
|
|
1816
1511
|
charset = 'iso-8859-1';
|
|
1817
1512
|
}
|
|
1818
|
-
|
|
1819
1513
|
skipIndex = i;
|
|
1820
1514
|
i = parts.length;
|
|
1821
1515
|
}
|
|
@@ -1826,12 +1520,10 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1826
1520
|
if (i === skipIndex) {
|
|
1827
1521
|
continue;
|
|
1828
1522
|
}
|
|
1829
|
-
|
|
1830
1523
|
var part = parts[i];
|
|
1831
1524
|
var bracketEqualsPos = part.indexOf(']=');
|
|
1832
1525
|
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
|
1833
1526
|
var key, val;
|
|
1834
|
-
|
|
1835
1527
|
if (pos === -1) {
|
|
1836
1528
|
key = options.decoder(part, defaults.decoder, charset, 'key');
|
|
1837
1529
|
val = options.strictNullHandling ? null : '';
|
|
@@ -1841,39 +1533,31 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1841
1533
|
return options.decoder(encodedVal, defaults.decoder, charset, 'value');
|
|
1842
1534
|
});
|
|
1843
1535
|
}
|
|
1844
|
-
|
|
1845
1536
|
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
|
1846
1537
|
val = interpretNumericEntities(val);
|
|
1847
1538
|
}
|
|
1848
|
-
|
|
1849
1539
|
if (part.indexOf('[]=') > -1) {
|
|
1850
1540
|
val = isArray(val) ? [val] : val;
|
|
1851
1541
|
}
|
|
1852
|
-
|
|
1853
1542
|
if (has.call(obj, key)) {
|
|
1854
1543
|
obj[key] = utils.combine(obj[key], val);
|
|
1855
1544
|
} else {
|
|
1856
1545
|
obj[key] = val;
|
|
1857
1546
|
}
|
|
1858
1547
|
}
|
|
1859
|
-
|
|
1860
1548
|
return obj;
|
|
1861
1549
|
};
|
|
1862
|
-
|
|
1863
1550
|
var parseObject = function (chain, val, options, valuesParsed) {
|
|
1864
1551
|
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
1865
|
-
|
|
1866
1552
|
for (var i = chain.length - 1; i >= 0; --i) {
|
|
1867
1553
|
var obj;
|
|
1868
1554
|
var root = chain[i];
|
|
1869
|
-
|
|
1870
1555
|
if (root === '[]' && options.parseArrays) {
|
|
1871
1556
|
obj = [].concat(leaf);
|
|
1872
1557
|
} else {
|
|
1873
1558
|
obj = options.plainObjects ? Object.create(null) : {};
|
|
1874
1559
|
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
|
1875
1560
|
var index = parseInt(cleanRoot, 10);
|
|
1876
|
-
|
|
1877
1561
|
if (!options.parseArrays && cleanRoot === '') {
|
|
1878
1562
|
obj = {
|
|
1879
1563
|
0: leaf
|
|
@@ -1885,69 +1569,59 @@ var parseObject = function (chain, val, options, valuesParsed) {
|
|
|
1885
1569
|
obj[cleanRoot] = leaf;
|
|
1886
1570
|
}
|
|
1887
1571
|
}
|
|
1888
|
-
|
|
1889
1572
|
leaf = obj;
|
|
1890
1573
|
}
|
|
1891
|
-
|
|
1892
1574
|
return leaf;
|
|
1893
1575
|
};
|
|
1894
|
-
|
|
1895
1576
|
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
|
|
1896
1577
|
if (!givenKey) {
|
|
1897
1578
|
return;
|
|
1898
1579
|
}
|
|
1899
1580
|
|
|
1900
1581
|
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
|
1582
|
+
|
|
1901
1583
|
var brackets = /(\[[^[\]]*])/;
|
|
1902
1584
|
var child = /(\[[^[\]]*])/g;
|
|
1585
|
+
|
|
1903
1586
|
var segment = options.depth > 0 && brackets.exec(key);
|
|
1904
1587
|
var parent = segment ? key.slice(0, segment.index) : key;
|
|
1905
|
-
var keys = [];
|
|
1906
1588
|
|
|
1589
|
+
var keys = [];
|
|
1907
1590
|
if (parent) {
|
|
1908
1591
|
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
|
1909
1592
|
if (!options.allowPrototypes) {
|
|
1910
1593
|
return;
|
|
1911
1594
|
}
|
|
1912
1595
|
}
|
|
1913
|
-
|
|
1914
1596
|
keys.push(parent);
|
|
1915
1597
|
}
|
|
1916
1598
|
|
|
1917
1599
|
var i = 0;
|
|
1918
|
-
|
|
1919
1600
|
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
|
|
1920
1601
|
i += 1;
|
|
1921
|
-
|
|
1922
1602
|
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
|
1923
1603
|
if (!options.allowPrototypes) {
|
|
1924
1604
|
return;
|
|
1925
1605
|
}
|
|
1926
1606
|
}
|
|
1927
|
-
|
|
1928
1607
|
keys.push(segment[1]);
|
|
1929
1608
|
}
|
|
1930
1609
|
|
|
1931
1610
|
if (segment) {
|
|
1932
1611
|
keys.push('[' + key.slice(segment.index) + ']');
|
|
1933
1612
|
}
|
|
1934
|
-
|
|
1935
1613
|
return parseObject(keys, val, options, valuesParsed);
|
|
1936
1614
|
};
|
|
1937
|
-
|
|
1938
1615
|
var normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
1939
1616
|
if (!opts) {
|
|
1940
1617
|
return defaults;
|
|
1941
1618
|
}
|
|
1942
|
-
|
|
1943
1619
|
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
|
1944
1620
|
throw new TypeError('Decoder has to be a function.');
|
|
1945
1621
|
}
|
|
1946
|
-
|
|
1947
1622
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
1948
1623
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
1949
1624
|
}
|
|
1950
|
-
|
|
1951
1625
|
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
|
1952
1626
|
return {
|
|
1953
1627
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
@@ -1968,28 +1642,23 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
|
1968
1642
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
1969
1643
|
};
|
|
1970
1644
|
};
|
|
1971
|
-
|
|
1972
1645
|
module.exports = function (str, opts) {
|
|
1973
1646
|
var options = normalizeParseOptions(opts);
|
|
1974
|
-
|
|
1975
1647
|
if (str === '' || str === null || typeof str === 'undefined') {
|
|
1976
1648
|
return options.plainObjects ? Object.create(null) : {};
|
|
1977
1649
|
}
|
|
1978
|
-
|
|
1979
1650
|
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
|
1980
1651
|
var obj = options.plainObjects ? Object.create(null) : {};
|
|
1981
|
-
var keys = Object.keys(tempObj);
|
|
1982
1652
|
|
|
1653
|
+
var keys = Object.keys(tempObj);
|
|
1983
1654
|
for (var i = 0; i < keys.length; ++i) {
|
|
1984
1655
|
var key = keys[i];
|
|
1985
1656
|
var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
|
|
1986
1657
|
obj = utils.merge(obj, newObj, options);
|
|
1987
1658
|
}
|
|
1988
|
-
|
|
1989
1659
|
if (options.allowSparse === true) {
|
|
1990
1660
|
return obj;
|
|
1991
1661
|
}
|
|
1992
|
-
|
|
1993
1662
|
return utils.compact(obj);
|
|
1994
1663
|
};
|
|
1995
1664
|
|
|
@@ -1997,11 +1666,8 @@ module.exports = function (str, opts) {
|
|
|
1997
1666
|
'use strict';
|
|
1998
1667
|
|
|
1999
1668
|
var getSideChannel = require('side-channel');
|
|
2000
|
-
|
|
2001
1669
|
var utils = require('./utils');
|
|
2002
|
-
|
|
2003
1670
|
var formats = require('./formats');
|
|
2004
|
-
|
|
2005
1671
|
var has = Object.prototype.hasOwnProperty;
|
|
2006
1672
|
var arrayPrefixGenerators = {
|
|
2007
1673
|
brackets: function brackets(prefix) {
|
|
@@ -2018,11 +1684,9 @@ var arrayPrefixGenerators = {
|
|
|
2018
1684
|
var isArray = Array.isArray;
|
|
2019
1685
|
var split = String.prototype.split;
|
|
2020
1686
|
var push = Array.prototype.push;
|
|
2021
|
-
|
|
2022
1687
|
var pushToArray = function (arr, valueOrArray) {
|
|
2023
1688
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
2024
1689
|
};
|
|
2025
|
-
|
|
2026
1690
|
var toISO = Date.prototype.toISOString;
|
|
2027
1691
|
var defaultFormat = formats['default'];
|
|
2028
1692
|
var defaults = {
|
|
@@ -2043,23 +1707,18 @@ var defaults = {
|
|
|
2043
1707
|
skipNulls: false,
|
|
2044
1708
|
strictNullHandling: false
|
|
2045
1709
|
};
|
|
2046
|
-
|
|
2047
1710
|
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
2048
1711
|
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'symbol' || typeof v === 'bigint';
|
|
2049
1712
|
};
|
|
2050
|
-
|
|
2051
1713
|
var sentinel = {};
|
|
2052
|
-
|
|
2053
1714
|
var stringify = function stringify(object, prefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
2054
1715
|
var obj = object;
|
|
2055
1716
|
var tmpSc = sideChannel;
|
|
2056
1717
|
var step = 0;
|
|
2057
1718
|
var findFlag = false;
|
|
2058
|
-
|
|
2059
1719
|
while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
|
|
2060
1720
|
var pos = tmpSc.get(object);
|
|
2061
1721
|
step += 1;
|
|
2062
|
-
|
|
2063
1722
|
if (typeof pos !== 'undefined') {
|
|
2064
1723
|
if (pos === step) {
|
|
2065
1724
|
throw new RangeError('Cyclic object value');
|
|
@@ -2072,7 +1731,6 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, commaRou
|
|
|
2072
1731
|
step = 0;
|
|
2073
1732
|
}
|
|
2074
1733
|
}
|
|
2075
|
-
|
|
2076
1734
|
if (typeof filter === 'function') {
|
|
2077
1735
|
obj = filter(prefix, obj);
|
|
2078
1736
|
} else if (obj instanceof Date) {
|
|
@@ -2082,48 +1740,35 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, commaRou
|
|
|
2082
1740
|
if (value instanceof Date) {
|
|
2083
1741
|
return serializeDate(value);
|
|
2084
1742
|
}
|
|
2085
|
-
|
|
2086
1743
|
return value;
|
|
2087
1744
|
});
|
|
2088
1745
|
}
|
|
2089
|
-
|
|
2090
1746
|
if (obj === null) {
|
|
2091
1747
|
if (strictNullHandling) {
|
|
2092
1748
|
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
|
|
2093
1749
|
}
|
|
2094
|
-
|
|
2095
1750
|
obj = '';
|
|
2096
1751
|
}
|
|
2097
|
-
|
|
2098
1752
|
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
|
|
2099
1753
|
if (encoder) {
|
|
2100
1754
|
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
|
|
2101
|
-
|
|
2102
1755
|
if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
|
|
2103
1756
|
var valuesArray = split.call(String(obj), ',');
|
|
2104
1757
|
var valuesJoined = '';
|
|
2105
|
-
|
|
2106
1758
|
for (var i = 0; i < valuesArray.length; ++i) {
|
|
2107
1759
|
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
|
|
2108
1760
|
}
|
|
2109
|
-
|
|
2110
1761
|
return [formatter(keyValue) + (commaRoundTrip && isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
|
|
2111
1762
|
}
|
|
2112
|
-
|
|
2113
1763
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
2114
1764
|
}
|
|
2115
|
-
|
|
2116
1765
|
return [formatter(prefix) + '=' + formatter(String(obj))];
|
|
2117
1766
|
}
|
|
2118
|
-
|
|
2119
1767
|
var values = [];
|
|
2120
|
-
|
|
2121
1768
|
if (typeof obj === 'undefined') {
|
|
2122
1769
|
return values;
|
|
2123
1770
|
}
|
|
2124
|
-
|
|
2125
1771
|
var objKeys;
|
|
2126
|
-
|
|
2127
1772
|
if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
|
2128
1773
|
objKeys = [{
|
|
2129
1774
|
value: obj.length > 0 ? obj.join(',') || null : void undefined
|
|
@@ -2134,59 +1779,44 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, commaRou
|
|
|
2134
1779
|
var keys = Object.keys(obj);
|
|
2135
1780
|
objKeys = sort ? keys.sort(sort) : keys;
|
|
2136
1781
|
}
|
|
2137
|
-
|
|
2138
1782
|
var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
|
|
2139
|
-
|
|
2140
1783
|
for (var j = 0; j < objKeys.length; ++j) {
|
|
2141
1784
|
var key = objKeys[j];
|
|
2142
1785
|
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
|
|
2143
|
-
|
|
2144
1786
|
if (skipNulls && value === null) {
|
|
2145
1787
|
continue;
|
|
2146
1788
|
}
|
|
2147
|
-
|
|
2148
1789
|
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
2149
1790
|
sideChannel.set(object, step);
|
|
2150
1791
|
var valueSideChannel = getSideChannel();
|
|
2151
1792
|
valueSideChannel.set(sentinel, sideChannel);
|
|
2152
1793
|
pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
2153
1794
|
}
|
|
2154
|
-
|
|
2155
1795
|
return values;
|
|
2156
1796
|
};
|
|
2157
|
-
|
|
2158
1797
|
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
2159
1798
|
if (!opts) {
|
|
2160
1799
|
return defaults;
|
|
2161
1800
|
}
|
|
2162
|
-
|
|
2163
1801
|
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
|
|
2164
1802
|
throw new TypeError('Encoder has to be a function.');
|
|
2165
1803
|
}
|
|
2166
|
-
|
|
2167
1804
|
var charset = opts.charset || defaults.charset;
|
|
2168
|
-
|
|
2169
1805
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
2170
1806
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
2171
1807
|
}
|
|
2172
|
-
|
|
2173
1808
|
var format = formats['default'];
|
|
2174
|
-
|
|
2175
1809
|
if (typeof opts.format !== 'undefined') {
|
|
2176
1810
|
if (!has.call(formats.formatters, opts.format)) {
|
|
2177
1811
|
throw new TypeError('Unknown format option provided.');
|
|
2178
1812
|
}
|
|
2179
|
-
|
|
2180
1813
|
format = opts.format;
|
|
2181
1814
|
}
|
|
2182
|
-
|
|
2183
1815
|
var formatter = formats.formatters[format];
|
|
2184
1816
|
var filter = defaults.filter;
|
|
2185
|
-
|
|
2186
1817
|
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
|
2187
1818
|
filter = opts.filter;
|
|
2188
1819
|
}
|
|
2189
|
-
|
|
2190
1820
|
return {
|
|
2191
1821
|
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
|
2192
1822
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
@@ -2205,13 +1835,11 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
|
2205
1835
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
2206
1836
|
};
|
|
2207
1837
|
};
|
|
2208
|
-
|
|
2209
1838
|
module.exports = function (object, opts) {
|
|
2210
1839
|
var obj = object;
|
|
2211
1840
|
var options = normalizeStringifyOptions(opts);
|
|
2212
1841
|
var objKeys;
|
|
2213
1842
|
var filter;
|
|
2214
|
-
|
|
2215
1843
|
if (typeof options.filter === 'function') {
|
|
2216
1844
|
filter = options.filter;
|
|
2217
1845
|
obj = filter('', obj);
|
|
@@ -2219,15 +1847,11 @@ module.exports = function (object, opts) {
|
|
|
2219
1847
|
filter = options.filter;
|
|
2220
1848
|
objKeys = filter;
|
|
2221
1849
|
}
|
|
2222
|
-
|
|
2223
1850
|
var keys = [];
|
|
2224
|
-
|
|
2225
1851
|
if (typeof obj !== 'object' || obj === null) {
|
|
2226
1852
|
return '';
|
|
2227
1853
|
}
|
|
2228
|
-
|
|
2229
1854
|
var arrayFormat;
|
|
2230
|
-
|
|
2231
1855
|
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
|
2232
1856
|
arrayFormat = opts.arrayFormat;
|
|
2233
1857
|
} else if (opts && 'indices' in opts) {
|
|
@@ -2235,38 +1859,27 @@ module.exports = function (object, opts) {
|
|
|
2235
1859
|
} else {
|
|
2236
1860
|
arrayFormat = 'indices';
|
|
2237
1861
|
}
|
|
2238
|
-
|
|
2239
1862
|
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
|
2240
|
-
|
|
2241
1863
|
if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
|
|
2242
1864
|
throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
|
|
2243
1865
|
}
|
|
2244
|
-
|
|
2245
1866
|
var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
|
|
2246
|
-
|
|
2247
1867
|
if (!objKeys) {
|
|
2248
1868
|
objKeys = Object.keys(obj);
|
|
2249
1869
|
}
|
|
2250
|
-
|
|
2251
1870
|
if (options.sort) {
|
|
2252
1871
|
objKeys.sort(options.sort);
|
|
2253
1872
|
}
|
|
2254
|
-
|
|
2255
1873
|
var sideChannel = getSideChannel();
|
|
2256
|
-
|
|
2257
1874
|
for (var i = 0; i < objKeys.length; ++i) {
|
|
2258
1875
|
var key = objKeys[i];
|
|
2259
|
-
|
|
2260
1876
|
if (options.skipNulls && obj[key] === null) {
|
|
2261
1877
|
continue;
|
|
2262
1878
|
}
|
|
2263
|
-
|
|
2264
1879
|
pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, commaRoundTrip, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
|
|
2265
1880
|
}
|
|
2266
|
-
|
|
2267
1881
|
var joined = keys.join(options.delimiter);
|
|
2268
1882
|
var prefix = options.addQueryPrefix === true ? '?' : '';
|
|
2269
|
-
|
|
2270
1883
|
if (options.charsetSentinel) {
|
|
2271
1884
|
if (options.charset === 'iso-8859-1') {
|
|
2272
1885
|
prefix += 'utf8=%26%2310003%3B&';
|
|
@@ -2274,7 +1887,6 @@ module.exports = function (object, opts) {
|
|
|
2274
1887
|
prefix += 'utf8=%E2%9C%93&';
|
|
2275
1888
|
}
|
|
2276
1889
|
}
|
|
2277
|
-
|
|
2278
1890
|
return joined.length > 0 ? prefix + joined : '';
|
|
2279
1891
|
};
|
|
2280
1892
|
|
|
@@ -2282,56 +1894,43 @@ module.exports = function (object, opts) {
|
|
|
2282
1894
|
'use strict';
|
|
2283
1895
|
|
|
2284
1896
|
var formats = require('./formats');
|
|
2285
|
-
|
|
2286
1897
|
var has = Object.prototype.hasOwnProperty;
|
|
2287
1898
|
var isArray = Array.isArray;
|
|
2288
|
-
|
|
2289
1899
|
var hexTable = function () {
|
|
2290
1900
|
var array = [];
|
|
2291
|
-
|
|
2292
1901
|
for (var i = 0; i < 256; ++i) {
|
|
2293
1902
|
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
2294
1903
|
}
|
|
2295
|
-
|
|
2296
1904
|
return array;
|
|
2297
1905
|
}();
|
|
2298
|
-
|
|
2299
1906
|
var compactQueue = function compactQueue(queue) {
|
|
2300
1907
|
while (queue.length > 1) {
|
|
2301
1908
|
var item = queue.pop();
|
|
2302
1909
|
var obj = item.obj[item.prop];
|
|
2303
|
-
|
|
2304
1910
|
if (isArray(obj)) {
|
|
2305
1911
|
var compacted = [];
|
|
2306
|
-
|
|
2307
1912
|
for (var j = 0; j < obj.length; ++j) {
|
|
2308
1913
|
if (typeof obj[j] !== 'undefined') {
|
|
2309
1914
|
compacted.push(obj[j]);
|
|
2310
1915
|
}
|
|
2311
1916
|
}
|
|
2312
|
-
|
|
2313
1917
|
item.obj[item.prop] = compacted;
|
|
2314
1918
|
}
|
|
2315
1919
|
}
|
|
2316
1920
|
};
|
|
2317
|
-
|
|
2318
1921
|
var arrayToObject = function arrayToObject(source, options) {
|
|
2319
1922
|
var obj = options && options.plainObjects ? Object.create(null) : {};
|
|
2320
|
-
|
|
2321
1923
|
for (var i = 0; i < source.length; ++i) {
|
|
2322
1924
|
if (typeof source[i] !== 'undefined') {
|
|
2323
1925
|
obj[i] = source[i];
|
|
2324
1926
|
}
|
|
2325
1927
|
}
|
|
2326
|
-
|
|
2327
1928
|
return obj;
|
|
2328
1929
|
};
|
|
2329
|
-
|
|
2330
1930
|
var merge = function merge(target, source, options) {
|
|
2331
1931
|
if (!source) {
|
|
2332
1932
|
return target;
|
|
2333
1933
|
}
|
|
2334
|
-
|
|
2335
1934
|
if (typeof source !== 'object') {
|
|
2336
1935
|
if (isArray(target)) {
|
|
2337
1936
|
target.push(source);
|
|
@@ -2342,25 +1941,19 @@ var merge = function merge(target, source, options) {
|
|
|
2342
1941
|
} else {
|
|
2343
1942
|
return [target, source];
|
|
2344
1943
|
}
|
|
2345
|
-
|
|
2346
1944
|
return target;
|
|
2347
1945
|
}
|
|
2348
|
-
|
|
2349
1946
|
if (!target || typeof target !== 'object') {
|
|
2350
1947
|
return [target].concat(source);
|
|
2351
1948
|
}
|
|
2352
|
-
|
|
2353
1949
|
var mergeTarget = target;
|
|
2354
|
-
|
|
2355
1950
|
if (isArray(target) && !isArray(source)) {
|
|
2356
1951
|
mergeTarget = arrayToObject(target, options);
|
|
2357
1952
|
}
|
|
2358
|
-
|
|
2359
1953
|
if (isArray(target) && isArray(source)) {
|
|
2360
1954
|
source.forEach(function (item, i) {
|
|
2361
1955
|
if (has.call(target, i)) {
|
|
2362
1956
|
var targetItem = target[i];
|
|
2363
|
-
|
|
2364
1957
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
2365
1958
|
target[i] = merge(targetItem, item, options);
|
|
2366
1959
|
} else {
|
|
@@ -2372,93 +1965,73 @@ var merge = function merge(target, source, options) {
|
|
|
2372
1965
|
});
|
|
2373
1966
|
return target;
|
|
2374
1967
|
}
|
|
2375
|
-
|
|
2376
1968
|
return Object.keys(source).reduce(function (acc, key) {
|
|
2377
1969
|
var value = source[key];
|
|
2378
|
-
|
|
2379
1970
|
if (has.call(acc, key)) {
|
|
2380
1971
|
acc[key] = merge(acc[key], value, options);
|
|
2381
1972
|
} else {
|
|
2382
1973
|
acc[key] = value;
|
|
2383
1974
|
}
|
|
2384
|
-
|
|
2385
1975
|
return acc;
|
|
2386
1976
|
}, mergeTarget);
|
|
2387
1977
|
};
|
|
2388
|
-
|
|
2389
1978
|
var assign = function assignSingleSource(target, source) {
|
|
2390
1979
|
return Object.keys(source).reduce(function (acc, key) {
|
|
2391
1980
|
acc[key] = source[key];
|
|
2392
1981
|
return acc;
|
|
2393
1982
|
}, target);
|
|
2394
1983
|
};
|
|
2395
|
-
|
|
2396
1984
|
var decode = function (str, decoder, charset) {
|
|
2397
1985
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
2398
|
-
|
|
2399
1986
|
if (charset === 'iso-8859-1') {
|
|
2400
1987
|
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
2401
1988
|
}
|
|
2402
|
-
|
|
2403
1989
|
try {
|
|
2404
1990
|
return decodeURIComponent(strWithoutPlus);
|
|
2405
1991
|
} catch (e) {
|
|
2406
1992
|
return strWithoutPlus;
|
|
2407
1993
|
}
|
|
2408
1994
|
};
|
|
2409
|
-
|
|
2410
1995
|
var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
2411
1996
|
if (str.length === 0) {
|
|
2412
1997
|
return str;
|
|
2413
1998
|
}
|
|
2414
|
-
|
|
2415
1999
|
var string = str;
|
|
2416
|
-
|
|
2417
2000
|
if (typeof str === 'symbol') {
|
|
2418
2001
|
string = Symbol.prototype.toString.call(str);
|
|
2419
2002
|
} else if (typeof str !== 'string') {
|
|
2420
2003
|
string = String(str);
|
|
2421
2004
|
}
|
|
2422
|
-
|
|
2423
2005
|
if (charset === 'iso-8859-1') {
|
|
2424
2006
|
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
2425
2007
|
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
2426
2008
|
});
|
|
2427
2009
|
}
|
|
2428
|
-
|
|
2429
2010
|
var out = '';
|
|
2430
|
-
|
|
2431
2011
|
for (var i = 0; i < string.length; ++i) {
|
|
2432
2012
|
var c = string.charCodeAt(i);
|
|
2433
|
-
|
|
2434
2013
|
if (c === 0x2D || c === 0x2E || c === 0x5F || c === 0x7E || c >= 0x30 && c <= 0x39 || c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || format === formats.RFC1738 && (c === 0x28 || c === 0x29)) {
|
|
2435
2014
|
out += string.charAt(i);
|
|
2436
2015
|
continue;
|
|
2437
2016
|
}
|
|
2438
|
-
|
|
2439
2017
|
if (c < 0x80) {
|
|
2440
2018
|
out = out + hexTable[c];
|
|
2441
2019
|
continue;
|
|
2442
2020
|
}
|
|
2443
|
-
|
|
2444
2021
|
if (c < 0x800) {
|
|
2445
2022
|
out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
|
|
2446
2023
|
continue;
|
|
2447
2024
|
}
|
|
2448
|
-
|
|
2449
2025
|
if (c < 0xD800 || c >= 0xE000) {
|
|
2450
2026
|
out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
|
|
2451
2027
|
continue;
|
|
2452
2028
|
}
|
|
2453
|
-
|
|
2454
2029
|
i += 1;
|
|
2455
2030
|
c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
|
|
2456
2031
|
out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
|
|
2457
2032
|
}
|
|
2458
|
-
|
|
2459
2033
|
return out;
|
|
2460
2034
|
};
|
|
2461
|
-
|
|
2462
2035
|
var compact = function compact(value) {
|
|
2463
2036
|
var queue = [{
|
|
2464
2037
|
obj: {
|
|
@@ -2467,16 +2040,13 @@ var compact = function compact(value) {
|
|
|
2467
2040
|
prop: 'o'
|
|
2468
2041
|
}];
|
|
2469
2042
|
var refs = [];
|
|
2470
|
-
|
|
2471
2043
|
for (var i = 0; i < queue.length; ++i) {
|
|
2472
2044
|
var item = queue[i];
|
|
2473
2045
|
var obj = item.obj[item.prop];
|
|
2474
2046
|
var keys = Object.keys(obj);
|
|
2475
|
-
|
|
2476
2047
|
for (var j = 0; j < keys.length; ++j) {
|
|
2477
2048
|
var key = keys[j];
|
|
2478
2049
|
var val = obj[key];
|
|
2479
|
-
|
|
2480
2050
|
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
2481
2051
|
queue.push({
|
|
2482
2052
|
obj: obj,
|
|
@@ -2486,41 +2056,31 @@ var compact = function compact(value) {
|
|
|
2486
2056
|
}
|
|
2487
2057
|
}
|
|
2488
2058
|
}
|
|
2489
|
-
|
|
2490
2059
|
compactQueue(queue);
|
|
2491
2060
|
return value;
|
|
2492
2061
|
};
|
|
2493
|
-
|
|
2494
2062
|
var isRegExp = function isRegExp(obj) {
|
|
2495
2063
|
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
2496
2064
|
};
|
|
2497
|
-
|
|
2498
2065
|
var isBuffer = function isBuffer(obj) {
|
|
2499
2066
|
if (!obj || typeof obj !== 'object') {
|
|
2500
2067
|
return false;
|
|
2501
2068
|
}
|
|
2502
|
-
|
|
2503
2069
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
2504
2070
|
};
|
|
2505
|
-
|
|
2506
2071
|
var combine = function combine(a, b) {
|
|
2507
2072
|
return [].concat(a, b);
|
|
2508
2073
|
};
|
|
2509
|
-
|
|
2510
2074
|
var maybeMap = function maybeMap(val, fn) {
|
|
2511
2075
|
if (isArray(val)) {
|
|
2512
2076
|
var mapped = [];
|
|
2513
|
-
|
|
2514
2077
|
for (var i = 0; i < val.length; i += 1) {
|
|
2515
2078
|
mapped.push(fn(val[i]));
|
|
2516
2079
|
}
|
|
2517
|
-
|
|
2518
2080
|
return mapped;
|
|
2519
2081
|
}
|
|
2520
|
-
|
|
2521
2082
|
return fn(val);
|
|
2522
2083
|
};
|
|
2523
|
-
|
|
2524
2084
|
module.exports = {
|
|
2525
2085
|
arrayToObject: arrayToObject,
|
|
2526
2086
|
assign: assign,
|
|
@@ -2538,11 +2098,8 @@ module.exports = {
|
|
|
2538
2098
|
'use strict';
|
|
2539
2099
|
|
|
2540
2100
|
var GetIntrinsic = require('get-intrinsic');
|
|
2541
|
-
|
|
2542
2101
|
var callBound = require('call-bind/callBound');
|
|
2543
|
-
|
|
2544
2102
|
var inspect = require('object-inspect');
|
|
2545
|
-
|
|
2546
2103
|
var $TypeError = GetIntrinsic('%TypeError%');
|
|
2547
2104
|
var $WeakMap = GetIntrinsic('%WeakMap%', true);
|
|
2548
2105
|
var $Map = GetIntrinsic('%Map%', true);
|
|
@@ -2563,15 +2120,12 @@ var listGetNode = function (list, key) {
|
|
|
2563
2120
|
}
|
|
2564
2121
|
}
|
|
2565
2122
|
};
|
|
2566
|
-
|
|
2567
2123
|
var listGet = function (objects, key) {
|
|
2568
2124
|
var node = listGetNode(objects, key);
|
|
2569
2125
|
return node && node.value;
|
|
2570
2126
|
};
|
|
2571
|
-
|
|
2572
2127
|
var listSet = function (objects, key, value) {
|
|
2573
2128
|
var node = listGetNode(objects, key);
|
|
2574
|
-
|
|
2575
2129
|
if (node) {
|
|
2576
2130
|
node.value = value;
|
|
2577
2131
|
} else {
|
|
@@ -2582,11 +2136,9 @@ var listSet = function (objects, key, value) {
|
|
|
2582
2136
|
};
|
|
2583
2137
|
}
|
|
2584
2138
|
};
|
|
2585
|
-
|
|
2586
2139
|
var listHas = function (objects, key) {
|
|
2587
2140
|
return !!listGetNode(objects, key);
|
|
2588
2141
|
};
|
|
2589
|
-
|
|
2590
2142
|
module.exports = function getSideChannel() {
|
|
2591
2143
|
var $wm;
|
|
2592
2144
|
var $m;
|
|
@@ -2626,7 +2178,6 @@ module.exports = function getSideChannel() {
|
|
|
2626
2178
|
return listHas($o, key);
|
|
2627
2179
|
}
|
|
2628
2180
|
}
|
|
2629
|
-
|
|
2630
2181
|
return false;
|
|
2631
2182
|
},
|
|
2632
2183
|
set: function (key, value) {
|
|
@@ -2634,13 +2185,11 @@ module.exports = function getSideChannel() {
|
|
|
2634
2185
|
if (!$wm) {
|
|
2635
2186
|
$wm = new $WeakMap();
|
|
2636
2187
|
}
|
|
2637
|
-
|
|
2638
2188
|
$weakMapSet($wm, key, value);
|
|
2639
2189
|
} else if ($Map) {
|
|
2640
2190
|
if (!$m) {
|
|
2641
2191
|
$m = new $Map();
|
|
2642
2192
|
}
|
|
2643
|
-
|
|
2644
2193
|
$mapSet($m, key, value);
|
|
2645
2194
|
} else {
|
|
2646
2195
|
if (!$o) {
|
|
@@ -2649,7 +2198,6 @@ module.exports = function getSideChannel() {
|
|
|
2649
2198
|
next: null
|
|
2650
2199
|
};
|
|
2651
2200
|
}
|
|
2652
|
-
|
|
2653
2201
|
listSet($o, key, value);
|
|
2654
2202
|
}
|
|
2655
2203
|
}
|
|
@@ -2661,33 +2209,29 @@ module.exports = function getSideChannel() {
|
|
|
2661
2209
|
function Agent() {
|
|
2662
2210
|
this._defaults = [];
|
|
2663
2211
|
}
|
|
2664
|
-
|
|
2665
2212
|
for (const fn of ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']) {
|
|
2666
2213
|
Agent.prototype[fn] = function () {
|
|
2667
2214
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2668
2215
|
args[_key] = arguments[_key];
|
|
2669
2216
|
}
|
|
2670
|
-
|
|
2671
2217
|
this._defaults.push({
|
|
2672
2218
|
fn,
|
|
2673
2219
|
args
|
|
2674
2220
|
});
|
|
2675
|
-
|
|
2676
2221
|
return this;
|
|
2677
2222
|
};
|
|
2678
2223
|
}
|
|
2679
|
-
|
|
2680
2224
|
Agent.prototype._setDefaults = function (request) {
|
|
2681
2225
|
for (const def of this._defaults) {
|
|
2682
2226
|
request[def.fn](...def.args);
|
|
2683
2227
|
}
|
|
2684
2228
|
};
|
|
2685
|
-
|
|
2686
2229
|
module.exports = Agent;
|
|
2687
2230
|
|
|
2688
2231
|
},{}],21:[function(require,module,exports){
|
|
2689
|
-
let root;
|
|
2690
2232
|
|
|
2233
|
+
|
|
2234
|
+
let root;
|
|
2691
2235
|
if (typeof window !== 'undefined') {
|
|
2692
2236
|
root = window;
|
|
2693
2237
|
} else if (typeof self === 'undefined') {
|
|
@@ -2696,23 +2240,16 @@ if (typeof window !== 'undefined') {
|
|
|
2696
2240
|
} else {
|
|
2697
2241
|
root = self;
|
|
2698
2242
|
}
|
|
2699
|
-
|
|
2700
2243
|
const Emitter = require('component-emitter');
|
|
2701
|
-
|
|
2702
2244
|
const safeStringify = require('fast-safe-stringify');
|
|
2703
|
-
|
|
2704
2245
|
const qs = require('qs');
|
|
2705
|
-
|
|
2706
2246
|
const RequestBase = require('./request-base');
|
|
2707
|
-
|
|
2708
2247
|
const {
|
|
2709
2248
|
isObject,
|
|
2710
2249
|
mixin,
|
|
2711
2250
|
hasOwn
|
|
2712
2251
|
} = require('./utils');
|
|
2713
|
-
|
|
2714
2252
|
const ResponseBase = require('./response-base');
|
|
2715
|
-
|
|
2716
2253
|
const Agent = require('./agent-base');
|
|
2717
2254
|
|
|
2718
2255
|
function noop() {}
|
|
@@ -2725,10 +2262,8 @@ module.exports = function (method, url) {
|
|
|
2725
2262
|
if (arguments.length === 1) {
|
|
2726
2263
|
return new exports.Request('GET', method);
|
|
2727
2264
|
}
|
|
2728
|
-
|
|
2729
2265
|
return new exports.Request(method, url);
|
|
2730
2266
|
};
|
|
2731
|
-
|
|
2732
2267
|
exports = module.exports;
|
|
2733
2268
|
const request = exports;
|
|
2734
2269
|
exports.Request = Request;
|
|
@@ -2737,7 +2272,6 @@ request.getXHR = () => {
|
|
|
2737
2272
|
if (root.XMLHttpRequest) {
|
|
2738
2273
|
return new root.XMLHttpRequest();
|
|
2739
2274
|
}
|
|
2740
|
-
|
|
2741
2275
|
throw new Error('Browser-only version of superagent could not find XHR');
|
|
2742
2276
|
};
|
|
2743
2277
|
|
|
@@ -2746,22 +2280,18 @@ const trim = ''.trim ? s => s.trim() : s => s.replace(/(^\s*|\s*$)/g, '');
|
|
|
2746
2280
|
function serialize(object) {
|
|
2747
2281
|
if (!isObject(object)) return object;
|
|
2748
2282
|
const pairs = [];
|
|
2749
|
-
|
|
2750
2283
|
for (const key in object) {
|
|
2751
2284
|
if (hasOwn(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
|
|
2752
2285
|
}
|
|
2753
|
-
|
|
2754
2286
|
return pairs.join('&');
|
|
2755
2287
|
}
|
|
2756
2288
|
|
|
2757
2289
|
function pushEncodedKeyValuePair(pairs, key, value) {
|
|
2758
2290
|
if (value === undefined) return;
|
|
2759
|
-
|
|
2760
2291
|
if (value === null) {
|
|
2761
2292
|
pairs.push(encodeURI(key));
|
|
2762
2293
|
return;
|
|
2763
2294
|
}
|
|
2764
|
-
|
|
2765
2295
|
if (Array.isArray(value)) {
|
|
2766
2296
|
for (const v of value) {
|
|
2767
2297
|
pushEncodedKeyValuePair(pairs, key, v);
|
|
@@ -2782,22 +2312,20 @@ function parseString(string_) {
|
|
|
2782
2312
|
const pairs = string_.split('&');
|
|
2783
2313
|
let pair;
|
|
2784
2314
|
let pos;
|
|
2785
|
-
|
|
2786
2315
|
for (let i = 0, length_ = pairs.length; i < length_; ++i) {
|
|
2787
2316
|
pair = pairs[i];
|
|
2788
2317
|
pos = pair.indexOf('=');
|
|
2789
|
-
|
|
2790
2318
|
if (pos === -1) {
|
|
2791
2319
|
object[decodeURIComponent(pair)] = '';
|
|
2792
2320
|
} else {
|
|
2793
2321
|
object[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1));
|
|
2794
2322
|
}
|
|
2795
2323
|
}
|
|
2796
|
-
|
|
2797
2324
|
return object;
|
|
2798
2325
|
}
|
|
2799
2326
|
|
|
2800
2327
|
request.parseString = parseString;
|
|
2328
|
+
|
|
2801
2329
|
request.types = {
|
|
2802
2330
|
html: 'text/html',
|
|
2803
2331
|
json: 'application/json',
|
|
@@ -2806,10 +2334,12 @@ request.types = {
|
|
|
2806
2334
|
form: 'application/x-www-form-urlencoded',
|
|
2807
2335
|
'form-data': 'application/x-www-form-urlencoded'
|
|
2808
2336
|
};
|
|
2337
|
+
|
|
2809
2338
|
request.serialize = {
|
|
2810
2339
|
'application/x-www-form-urlencoded': qs.stringify,
|
|
2811
2340
|
'application/json': safeStringify
|
|
2812
2341
|
};
|
|
2342
|
+
|
|
2813
2343
|
request.parse = {
|
|
2814
2344
|
'application/x-www-form-urlencoded': parseString,
|
|
2815
2345
|
'application/json': JSON.parse
|
|
@@ -2822,20 +2352,16 @@ function parseHeader(string_) {
|
|
|
2822
2352
|
let line;
|
|
2823
2353
|
let field;
|
|
2824
2354
|
let value;
|
|
2825
|
-
|
|
2826
2355
|
for (let i = 0, length_ = lines.length; i < length_; ++i) {
|
|
2827
2356
|
line = lines[i];
|
|
2828
2357
|
index = line.indexOf(':');
|
|
2829
|
-
|
|
2830
2358
|
if (index === -1) {
|
|
2831
2359
|
continue;
|
|
2832
2360
|
}
|
|
2833
|
-
|
|
2834
2361
|
field = line.slice(0, index).toLowerCase();
|
|
2835
2362
|
value = trim(line.slice(index + 1));
|
|
2836
2363
|
fields[field] = value;
|
|
2837
2364
|
}
|
|
2838
|
-
|
|
2839
2365
|
return fields;
|
|
2840
2366
|
}
|
|
2841
2367
|
|
|
@@ -2851,39 +2377,30 @@ function Response(request_) {
|
|
|
2851
2377
|
let {
|
|
2852
2378
|
status
|
|
2853
2379
|
} = this.xhr;
|
|
2854
|
-
|
|
2855
2380
|
if (status === 1223) {
|
|
2856
2381
|
status = 204;
|
|
2857
2382
|
}
|
|
2858
|
-
|
|
2859
2383
|
this._setStatusProperties(status);
|
|
2860
|
-
|
|
2861
2384
|
this.headers = parseHeader(this.xhr.getAllResponseHeaders());
|
|
2862
2385
|
this.header = this.headers;
|
|
2863
2386
|
this.header['content-type'] = this.xhr.getResponseHeader('content-type');
|
|
2864
|
-
|
|
2865
2387
|
this._setHeaderProperties(this.header);
|
|
2866
|
-
|
|
2867
2388
|
if (this.text === null && request_._responseType) {
|
|
2868
2389
|
this.body = this.xhr.response;
|
|
2869
2390
|
} else {
|
|
2870
2391
|
this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response);
|
|
2871
2392
|
}
|
|
2872
2393
|
}
|
|
2873
|
-
|
|
2874
2394
|
mixin(Response.prototype, ResponseBase.prototype);
|
|
2875
2395
|
|
|
2876
2396
|
Response.prototype._parseBody = function (string_) {
|
|
2877
2397
|
let parse = request.parse[this.type];
|
|
2878
|
-
|
|
2879
2398
|
if (this.req._parser) {
|
|
2880
2399
|
return this.req._parser(this, string_);
|
|
2881
2400
|
}
|
|
2882
|
-
|
|
2883
2401
|
if (!parse && isJSON(this.type)) {
|
|
2884
2402
|
parse = request.parse['application/json'];
|
|
2885
2403
|
}
|
|
2886
|
-
|
|
2887
2404
|
return parse && string_ && (string_.length > 0 || string_ instanceof Object) ? parse(string_) : null;
|
|
2888
2405
|
};
|
|
2889
2406
|
|
|
@@ -2917,14 +2434,12 @@ function Request(method, url) {
|
|
|
2917
2434
|
this.on('end', () => {
|
|
2918
2435
|
let error = null;
|
|
2919
2436
|
let res = null;
|
|
2920
|
-
|
|
2921
2437
|
try {
|
|
2922
2438
|
res = new Response(self);
|
|
2923
2439
|
} catch (err) {
|
|
2924
2440
|
error = new Error('Parser is unable to parse the response');
|
|
2925
2441
|
error.parse = true;
|
|
2926
2442
|
error.original = err;
|
|
2927
|
-
|
|
2928
2443
|
if (self.xhr) {
|
|
2929
2444
|
error.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response;
|
|
2930
2445
|
error.status = self.xhr.status ? self.xhr.status : null;
|
|
@@ -2933,13 +2448,10 @@ function Request(method, url) {
|
|
|
2933
2448
|
error.rawResponse = null;
|
|
2934
2449
|
error.status = null;
|
|
2935
2450
|
}
|
|
2936
|
-
|
|
2937
2451
|
return self.callback(error);
|
|
2938
2452
|
}
|
|
2939
|
-
|
|
2940
2453
|
self.emit('response', res);
|
|
2941
2454
|
let new_error;
|
|
2942
|
-
|
|
2943
2455
|
try {
|
|
2944
2456
|
if (!self._isResponseOK(res)) {
|
|
2945
2457
|
new_error = new Error(res.statusText || res.text || 'Unsuccessful HTTP response');
|
|
@@ -2974,23 +2486,19 @@ Request.prototype.accept = function (type) {
|
|
|
2974
2486
|
|
|
2975
2487
|
Request.prototype.auth = function (user, pass, options) {
|
|
2976
2488
|
if (arguments.length === 1) pass = '';
|
|
2977
|
-
|
|
2978
2489
|
if (typeof pass === 'object' && pass !== null) {
|
|
2979
2490
|
options = pass;
|
|
2980
2491
|
pass = '';
|
|
2981
2492
|
}
|
|
2982
|
-
|
|
2983
2493
|
if (!options) {
|
|
2984
2494
|
options = {
|
|
2985
2495
|
type: typeof btoa === 'function' ? 'basic' : 'auto'
|
|
2986
2496
|
};
|
|
2987
2497
|
}
|
|
2988
|
-
|
|
2989
2498
|
const encoder = options.encoder ? options.encoder : string => {
|
|
2990
2499
|
if (typeof btoa === 'function') {
|
|
2991
2500
|
return btoa(string);
|
|
2992
2501
|
}
|
|
2993
|
-
|
|
2994
2502
|
throw new Error('Cannot use basic auth, btoa is not a function');
|
|
2995
2503
|
};
|
|
2996
2504
|
return this._auth(user, pass, options, encoder);
|
|
@@ -3007,18 +2515,14 @@ Request.prototype.attach = function (field, file, options) {
|
|
|
3007
2515
|
if (this._data) {
|
|
3008
2516
|
throw new Error("superagent can't mix .send() and .attach()");
|
|
3009
2517
|
}
|
|
3010
|
-
|
|
3011
2518
|
this._getFormData().append(field, file, options || file.name);
|
|
3012
2519
|
}
|
|
3013
|
-
|
|
3014
2520
|
return this;
|
|
3015
2521
|
};
|
|
3016
|
-
|
|
3017
2522
|
Request.prototype._getFormData = function () {
|
|
3018
2523
|
if (!this._formData) {
|
|
3019
2524
|
this._formData = new root.FormData();
|
|
3020
2525
|
}
|
|
3021
|
-
|
|
3022
2526
|
return this._formData;
|
|
3023
2527
|
};
|
|
3024
2528
|
|
|
@@ -3026,15 +2530,12 @@ Request.prototype.callback = function (error, res) {
|
|
|
3026
2530
|
if (this._shouldRetry(error, res)) {
|
|
3027
2531
|
return this._retry();
|
|
3028
2532
|
}
|
|
3029
|
-
|
|
3030
2533
|
const fn = this._callback;
|
|
3031
2534
|
this.clearTimeout();
|
|
3032
|
-
|
|
3033
2535
|
if (error) {
|
|
3034
2536
|
if (this._maxRetries) error.retries = this._retries - 1;
|
|
3035
2537
|
this.emit('error', error);
|
|
3036
2538
|
}
|
|
3037
|
-
|
|
3038
2539
|
fn(error, res);
|
|
3039
2540
|
};
|
|
3040
2541
|
|
|
@@ -3051,14 +2552,12 @@ Request.prototype.agent = function () {
|
|
|
3051
2552
|
console.warn('This is not supported in browser version of superagent');
|
|
3052
2553
|
return this;
|
|
3053
2554
|
};
|
|
3054
|
-
|
|
3055
2555
|
Request.prototype.ca = Request.prototype.agent;
|
|
3056
2556
|
Request.prototype.buffer = Request.prototype.ca;
|
|
3057
2557
|
|
|
3058
2558
|
Request.prototype.write = () => {
|
|
3059
2559
|
throw new Error('Streaming is not supported in browser version of superagent');
|
|
3060
2560
|
};
|
|
3061
|
-
|
|
3062
2561
|
Request.prototype.pipe = Request.prototype.write;
|
|
3063
2562
|
|
|
3064
2563
|
Request.prototype._isHost = function (object) {
|
|
@@ -3069,15 +2568,13 @@ Request.prototype.end = function (fn) {
|
|
|
3069
2568
|
if (this._endCalled) {
|
|
3070
2569
|
console.warn('Warning: .end() was called twice. This is not supported in superagent');
|
|
3071
2570
|
}
|
|
3072
|
-
|
|
3073
2571
|
this._endCalled = true;
|
|
2572
|
+
|
|
3074
2573
|
this._callback = fn || noop;
|
|
3075
2574
|
|
|
3076
2575
|
this._finalizeQueryString();
|
|
3077
|
-
|
|
3078
2576
|
this._end();
|
|
3079
2577
|
};
|
|
3080
|
-
|
|
3081
2578
|
Request.prototype._setUploadTimeout = function () {
|
|
3082
2579
|
const self = this;
|
|
3083
2580
|
|
|
@@ -3096,61 +2593,51 @@ Request.prototype._end = function () {
|
|
|
3096
2593
|
xhr
|
|
3097
2594
|
} = this;
|
|
3098
2595
|
let data = this._formData || this._data;
|
|
3099
|
-
|
|
3100
2596
|
this._setTimeouts();
|
|
3101
2597
|
|
|
3102
2598
|
xhr.addEventListener('readystatechange', () => {
|
|
3103
2599
|
const {
|
|
3104
2600
|
readyState
|
|
3105
2601
|
} = xhr;
|
|
3106
|
-
|
|
3107
2602
|
if (readyState >= 2 && self._responseTimeoutTimer) {
|
|
3108
2603
|
clearTimeout(self._responseTimeoutTimer);
|
|
3109
2604
|
}
|
|
3110
|
-
|
|
3111
2605
|
if (readyState !== 4) {
|
|
3112
2606
|
return;
|
|
3113
2607
|
}
|
|
3114
2608
|
|
|
3115
2609
|
let status;
|
|
3116
|
-
|
|
3117
2610
|
try {
|
|
3118
2611
|
status = xhr.status;
|
|
3119
2612
|
} catch (err) {
|
|
3120
2613
|
status = 0;
|
|
3121
2614
|
}
|
|
3122
|
-
|
|
3123
2615
|
if (!status) {
|
|
3124
2616
|
if (self.timedout || self._aborted) return;
|
|
3125
2617
|
return self.crossDomainError();
|
|
3126
2618
|
}
|
|
3127
|
-
|
|
3128
2619
|
self.emit('end');
|
|
3129
2620
|
});
|
|
3130
2621
|
|
|
3131
2622
|
const handleProgress = (direction, e) => {
|
|
3132
2623
|
if (e.total > 0) {
|
|
3133
2624
|
e.percent = e.loaded / e.total * 100;
|
|
3134
|
-
|
|
3135
2625
|
if (e.percent === 100) {
|
|
3136
2626
|
clearTimeout(self._uploadTimeoutTimer);
|
|
3137
2627
|
}
|
|
3138
2628
|
}
|
|
3139
|
-
|
|
3140
2629
|
e.direction = direction;
|
|
3141
2630
|
self.emit('progress', e);
|
|
3142
2631
|
};
|
|
3143
|
-
|
|
3144
2632
|
if (this.hasListeners('progress')) {
|
|
3145
2633
|
try {
|
|
3146
2634
|
xhr.addEventListener('progress', handleProgress.bind(null, 'download'));
|
|
3147
|
-
|
|
3148
2635
|
if (xhr.upload) {
|
|
3149
2636
|
xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
|
|
3150
2637
|
}
|
|
3151
|
-
} catch (err) {
|
|
2638
|
+
} catch (err) {
|
|
2639
|
+
}
|
|
3152
2640
|
}
|
|
3153
|
-
|
|
3154
2641
|
if (xhr.upload) {
|
|
3155
2642
|
this._setUploadTimeout();
|
|
3156
2643
|
}
|
|
@@ -3170,11 +2657,9 @@ Request.prototype._end = function () {
|
|
|
3170
2657
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
3171
2658
|
const contentType = this._header['content-type'];
|
|
3172
2659
|
let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
3173
|
-
|
|
3174
2660
|
if (!serialize && isJSON(contentType)) {
|
|
3175
2661
|
serialize = request.serialize['application/json'];
|
|
3176
2662
|
}
|
|
3177
|
-
|
|
3178
2663
|
if (serialize) data = serialize(data);
|
|
3179
2664
|
}
|
|
3180
2665
|
|
|
@@ -3182,41 +2667,33 @@ Request.prototype._end = function () {
|
|
|
3182
2667
|
if (this.header[field] === null) continue;
|
|
3183
2668
|
if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
|
|
3184
2669
|
}
|
|
3185
|
-
|
|
3186
2670
|
if (this._responseType) {
|
|
3187
2671
|
xhr.responseType = this._responseType;
|
|
3188
2672
|
}
|
|
3189
2673
|
|
|
3190
2674
|
this.emit('request', this);
|
|
2675
|
+
|
|
3191
2676
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
3192
2677
|
};
|
|
3193
|
-
|
|
3194
2678
|
request.agent = () => new Agent();
|
|
3195
|
-
|
|
3196
2679
|
for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
|
|
3197
2680
|
Agent.prototype[method.toLowerCase()] = function (url, fn) {
|
|
3198
2681
|
const request_ = new request.Request(method, url);
|
|
3199
|
-
|
|
3200
2682
|
this._setDefaults(request_);
|
|
3201
|
-
|
|
3202
2683
|
if (fn) {
|
|
3203
2684
|
request_.end(fn);
|
|
3204
2685
|
}
|
|
3205
|
-
|
|
3206
2686
|
return request_;
|
|
3207
2687
|
};
|
|
3208
2688
|
}
|
|
3209
|
-
|
|
3210
2689
|
Agent.prototype.del = Agent.prototype.delete;
|
|
3211
2690
|
|
|
3212
2691
|
request.get = (url, data, fn) => {
|
|
3213
2692
|
const request_ = request('GET', url);
|
|
3214
|
-
|
|
3215
2693
|
if (typeof data === 'function') {
|
|
3216
2694
|
fn = data;
|
|
3217
2695
|
data = null;
|
|
3218
2696
|
}
|
|
3219
|
-
|
|
3220
2697
|
if (data) request_.query(data);
|
|
3221
2698
|
if (fn) request_.end(fn);
|
|
3222
2699
|
return request_;
|
|
@@ -3224,12 +2701,10 @@ request.get = (url, data, fn) => {
|
|
|
3224
2701
|
|
|
3225
2702
|
request.head = (url, data, fn) => {
|
|
3226
2703
|
const request_ = request('HEAD', url);
|
|
3227
|
-
|
|
3228
2704
|
if (typeof data === 'function') {
|
|
3229
2705
|
fn = data;
|
|
3230
2706
|
data = null;
|
|
3231
2707
|
}
|
|
3232
|
-
|
|
3233
2708
|
if (data) request_.query(data);
|
|
3234
2709
|
if (fn) request_.end(fn);
|
|
3235
2710
|
return request_;
|
|
@@ -3237,12 +2712,10 @@ request.head = (url, data, fn) => {
|
|
|
3237
2712
|
|
|
3238
2713
|
request.options = (url, data, fn) => {
|
|
3239
2714
|
const request_ = request('OPTIONS', url);
|
|
3240
|
-
|
|
3241
2715
|
if (typeof data === 'function') {
|
|
3242
2716
|
fn = data;
|
|
3243
2717
|
data = null;
|
|
3244
2718
|
}
|
|
3245
|
-
|
|
3246
2719
|
if (data) request_.send(data);
|
|
3247
2720
|
if (fn) request_.end(fn);
|
|
3248
2721
|
return request_;
|
|
@@ -3250,28 +2723,23 @@ request.options = (url, data, fn) => {
|
|
|
3250
2723
|
|
|
3251
2724
|
function del(url, data, fn) {
|
|
3252
2725
|
const request_ = request('DELETE', url);
|
|
3253
|
-
|
|
3254
2726
|
if (typeof data === 'function') {
|
|
3255
2727
|
fn = data;
|
|
3256
2728
|
data = null;
|
|
3257
2729
|
}
|
|
3258
|
-
|
|
3259
2730
|
if (data) request_.send(data);
|
|
3260
2731
|
if (fn) request_.end(fn);
|
|
3261
2732
|
return request_;
|
|
3262
2733
|
}
|
|
3263
|
-
|
|
3264
2734
|
request.del = del;
|
|
3265
2735
|
request.delete = del;
|
|
3266
2736
|
|
|
3267
2737
|
request.patch = (url, data, fn) => {
|
|
3268
2738
|
const request_ = request('PATCH', url);
|
|
3269
|
-
|
|
3270
2739
|
if (typeof data === 'function') {
|
|
3271
2740
|
fn = data;
|
|
3272
2741
|
data = null;
|
|
3273
2742
|
}
|
|
3274
|
-
|
|
3275
2743
|
if (data) request_.send(data);
|
|
3276
2744
|
if (fn) request_.end(fn);
|
|
3277
2745
|
return request_;
|
|
@@ -3279,12 +2747,10 @@ request.patch = (url, data, fn) => {
|
|
|
3279
2747
|
|
|
3280
2748
|
request.post = (url, data, fn) => {
|
|
3281
2749
|
const request_ = request('POST', url);
|
|
3282
|
-
|
|
3283
2750
|
if (typeof data === 'function') {
|
|
3284
2751
|
fn = data;
|
|
3285
2752
|
data = null;
|
|
3286
2753
|
}
|
|
3287
|
-
|
|
3288
2754
|
if (data) request_.send(data);
|
|
3289
2755
|
if (fn) request_.end(fn);
|
|
3290
2756
|
return request_;
|
|
@@ -3292,12 +2758,10 @@ request.post = (url, data, fn) => {
|
|
|
3292
2758
|
|
|
3293
2759
|
request.put = (url, data, fn) => {
|
|
3294
2760
|
const request_ = request('PUT', url);
|
|
3295
|
-
|
|
3296
2761
|
if (typeof data === 'function') {
|
|
3297
2762
|
fn = data;
|
|
3298
2763
|
data = null;
|
|
3299
2764
|
}
|
|
3300
|
-
|
|
3301
2765
|
if (data) request_.send(data);
|
|
3302
2766
|
if (fn) request_.end(fn);
|
|
3303
2767
|
return request_;
|
|
@@ -3348,28 +2812,23 @@ RequestBase.prototype.timeout = function (options) {
|
|
|
3348
2812
|
this._uploadTimeout = 0;
|
|
3349
2813
|
return this;
|
|
3350
2814
|
}
|
|
3351
|
-
|
|
3352
2815
|
for (const option in options) {
|
|
3353
2816
|
if (hasOwn(options, option)) {
|
|
3354
2817
|
switch (option) {
|
|
3355
2818
|
case 'deadline':
|
|
3356
2819
|
this._timeout = options.deadline;
|
|
3357
2820
|
break;
|
|
3358
|
-
|
|
3359
2821
|
case 'response':
|
|
3360
2822
|
this._responseTimeout = options.response;
|
|
3361
2823
|
break;
|
|
3362
|
-
|
|
3363
2824
|
case 'upload':
|
|
3364
2825
|
this._uploadTimeout = options.upload;
|
|
3365
2826
|
break;
|
|
3366
|
-
|
|
3367
2827
|
default:
|
|
3368
2828
|
console.warn('Unknown timeout option', option);
|
|
3369
2829
|
}
|
|
3370
2830
|
}
|
|
3371
2831
|
}
|
|
3372
|
-
|
|
3373
2832
|
return this;
|
|
3374
2833
|
};
|
|
3375
2834
|
|
|
@@ -3389,11 +2848,9 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
3389
2848
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
3390
2849
|
return false;
|
|
3391
2850
|
}
|
|
3392
|
-
|
|
3393
2851
|
if (this._retryCallback) {
|
|
3394
2852
|
try {
|
|
3395
2853
|
const override = this._retryCallback(error, res);
|
|
3396
|
-
|
|
3397
2854
|
if (override === true) return true;
|
|
3398
2855
|
if (override === false) return false;
|
|
3399
2856
|
} catch (err) {
|
|
@@ -3402,13 +2859,11 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
3402
2859
|
}
|
|
3403
2860
|
|
|
3404
2861
|
if (res && res.status && STATUS_CODES.has(res.status)) return true;
|
|
3405
|
-
|
|
3406
2862
|
if (error) {
|
|
3407
2863
|
if (error.code && ERROR_CODES.has(error.code)) return true;
|
|
3408
2864
|
if (error.timeout && error.code === 'ECONNABORTED') return true;
|
|
3409
2865
|
if (error.crossDomain) return true;
|
|
3410
2866
|
}
|
|
3411
|
-
|
|
3412
2867
|
return false;
|
|
3413
2868
|
};
|
|
3414
2869
|
|
|
@@ -3419,7 +2874,6 @@ RequestBase.prototype._retry = function () {
|
|
|
3419
2874
|
this.req = null;
|
|
3420
2875
|
this.req = this.request();
|
|
3421
2876
|
}
|
|
3422
|
-
|
|
3423
2877
|
this._aborted = false;
|
|
3424
2878
|
this.timedout = false;
|
|
3425
2879
|
this.timedoutError = null;
|
|
@@ -3429,22 +2883,18 @@ RequestBase.prototype._retry = function () {
|
|
|
3429
2883
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
3430
2884
|
if (!this._fullfilledPromise) {
|
|
3431
2885
|
const self = this;
|
|
3432
|
-
|
|
3433
2886
|
if (this._endCalled) {
|
|
3434
2887
|
console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');
|
|
3435
2888
|
}
|
|
3436
|
-
|
|
3437
2889
|
this._fullfilledPromise = new Promise((resolve, reject) => {
|
|
3438
2890
|
self.on('abort', () => {
|
|
3439
2891
|
if (this._maxRetries && this._maxRetries > this._retries) {
|
|
3440
2892
|
return;
|
|
3441
2893
|
}
|
|
3442
|
-
|
|
3443
2894
|
if (this.timedout && this.timedoutError) {
|
|
3444
2895
|
reject(this.timedoutError);
|
|
3445
2896
|
return;
|
|
3446
2897
|
}
|
|
3447
|
-
|
|
3448
2898
|
const error = new Error('Aborted');
|
|
3449
2899
|
error.code = 'ABORTED';
|
|
3450
2900
|
error.status = this.status;
|
|
@@ -3457,10 +2907,8 @@ RequestBase.prototype.then = function (resolve, reject) {
|
|
|
3457
2907
|
});
|
|
3458
2908
|
});
|
|
3459
2909
|
}
|
|
3460
|
-
|
|
3461
2910
|
return this._fullfilledPromise.then(resolve, reject);
|
|
3462
2911
|
};
|
|
3463
|
-
|
|
3464
2912
|
RequestBase.prototype.catch = function (callback) {
|
|
3465
2913
|
return this.then(undefined, callback);
|
|
3466
2914
|
};
|
|
@@ -3469,22 +2917,18 @@ RequestBase.prototype.use = function (fn) {
|
|
|
3469
2917
|
fn(this);
|
|
3470
2918
|
return this;
|
|
3471
2919
|
};
|
|
3472
|
-
|
|
3473
2920
|
RequestBase.prototype.ok = function (callback) {
|
|
3474
2921
|
if (typeof callback !== 'function') throw new Error('Callback required');
|
|
3475
2922
|
this._okCallback = callback;
|
|
3476
2923
|
return this;
|
|
3477
2924
|
};
|
|
3478
|
-
|
|
3479
2925
|
RequestBase.prototype._isResponseOK = function (res) {
|
|
3480
2926
|
if (!res) {
|
|
3481
2927
|
return false;
|
|
3482
2928
|
}
|
|
3483
|
-
|
|
3484
2929
|
if (this._okCallback) {
|
|
3485
2930
|
return this._okCallback(res);
|
|
3486
2931
|
}
|
|
3487
|
-
|
|
3488
2932
|
return res.status >= 200 && res.status < 300;
|
|
3489
2933
|
};
|
|
3490
2934
|
|
|
@@ -3499,10 +2943,8 @@ RequestBase.prototype.set = function (field, value) {
|
|
|
3499
2943
|
for (const key in field) {
|
|
3500
2944
|
if (hasOwn(field, key)) this.set(key, field[key]);
|
|
3501
2945
|
}
|
|
3502
|
-
|
|
3503
2946
|
return this;
|
|
3504
2947
|
}
|
|
3505
|
-
|
|
3506
2948
|
this._header[field.toLowerCase()] = value;
|
|
3507
2949
|
this.header[field] = value;
|
|
3508
2950
|
return this;
|
|
@@ -3518,31 +2960,25 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3518
2960
|
if (name === null || undefined === name) {
|
|
3519
2961
|
throw new Error('.field(name, val) name can not be empty');
|
|
3520
2962
|
}
|
|
3521
|
-
|
|
3522
2963
|
if (this._data) {
|
|
3523
2964
|
throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");
|
|
3524
2965
|
}
|
|
3525
|
-
|
|
3526
2966
|
if (isObject(name)) {
|
|
3527
2967
|
for (const key in name) {
|
|
3528
2968
|
if (hasOwn(name, key)) this.field(key, name[key]);
|
|
3529
2969
|
}
|
|
3530
|
-
|
|
3531
2970
|
return this;
|
|
3532
2971
|
}
|
|
3533
|
-
|
|
3534
2972
|
if (Array.isArray(value)) {
|
|
3535
2973
|
for (const i in value) {
|
|
3536
2974
|
if (hasOwn(value, i)) this.field(name, value[i]);
|
|
3537
2975
|
}
|
|
3538
|
-
|
|
3539
2976
|
return this;
|
|
3540
2977
|
}
|
|
3541
2978
|
|
|
3542
2979
|
if (value === null || undefined === value) {
|
|
3543
2980
|
throw new Error('.field(name, val) val can not be empty');
|
|
3544
2981
|
}
|
|
3545
|
-
|
|
3546
2982
|
if (typeof value === 'boolean') {
|
|
3547
2983
|
value = String(value);
|
|
3548
2984
|
}
|
|
@@ -3555,17 +2991,14 @@ RequestBase.prototype.abort = function () {
|
|
|
3555
2991
|
if (this._aborted) {
|
|
3556
2992
|
return this;
|
|
3557
2993
|
}
|
|
3558
|
-
|
|
3559
2994
|
this._aborted = true;
|
|
3560
2995
|
if (this.xhr) this.xhr.abort();
|
|
3561
|
-
|
|
3562
2996
|
if (this.req) {
|
|
3563
2997
|
if (semver.gte(process.version, 'v13.0.0') && semver.lt(process.version, 'v14.0.0')) {
|
|
3564
2998
|
throw new Error('Superagent does not work in v13 properly with abort() due to Node.js core changes');
|
|
3565
2999
|
} else if (semver.gte(process.version, 'v14.0.0')) {
|
|
3566
3000
|
this.req.destroyed = true;
|
|
3567
3001
|
}
|
|
3568
|
-
|
|
3569
3002
|
this.req.abort();
|
|
3570
3003
|
}
|
|
3571
3004
|
|
|
@@ -3573,26 +3006,21 @@ RequestBase.prototype.abort = function () {
|
|
|
3573
3006
|
this.emit('abort');
|
|
3574
3007
|
return this;
|
|
3575
3008
|
};
|
|
3576
|
-
|
|
3577
3009
|
RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
3578
3010
|
switch (options.type) {
|
|
3579
3011
|
case 'basic':
|
|
3580
3012
|
this.set('Authorization', `Basic ${base64Encoder(`${user}:${pass}`)}`);
|
|
3581
3013
|
break;
|
|
3582
|
-
|
|
3583
3014
|
case 'auto':
|
|
3584
3015
|
this.username = user;
|
|
3585
3016
|
this.password = pass;
|
|
3586
3017
|
break;
|
|
3587
|
-
|
|
3588
3018
|
case 'bearer':
|
|
3589
3019
|
this.set('Authorization', `Bearer ${user}`);
|
|
3590
3020
|
break;
|
|
3591
|
-
|
|
3592
3021
|
default:
|
|
3593
3022
|
break;
|
|
3594
3023
|
}
|
|
3595
|
-
|
|
3596
3024
|
return this;
|
|
3597
3025
|
};
|
|
3598
3026
|
|
|
@@ -3611,7 +3039,6 @@ RequestBase.prototype.maxResponseSize = function (n) {
|
|
|
3611
3039
|
if (typeof n !== 'number') {
|
|
3612
3040
|
throw new TypeError('Invalid argument');
|
|
3613
3041
|
}
|
|
3614
|
-
|
|
3615
3042
|
this._maxResponseSize = n;
|
|
3616
3043
|
return this;
|
|
3617
3044
|
};
|
|
@@ -3628,11 +3055,9 @@ RequestBase.prototype.toJSON = function () {
|
|
|
3628
3055
|
RequestBase.prototype.send = function (data) {
|
|
3629
3056
|
const isObject_ = isObject(data);
|
|
3630
3057
|
let type = this._header['content-type'];
|
|
3631
|
-
|
|
3632
3058
|
if (this._formData) {
|
|
3633
3059
|
throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
|
|
3634
3060
|
}
|
|
3635
|
-
|
|
3636
3061
|
if (isObject_ && !this._data) {
|
|
3637
3062
|
if (Array.isArray(data)) {
|
|
3638
3063
|
this._data = [];
|
|
@@ -3651,7 +3076,6 @@ RequestBase.prototype.send = function (data) {
|
|
|
3651
3076
|
if (!type) this.type('form');
|
|
3652
3077
|
type = this._header['content-type'];
|
|
3653
3078
|
if (type) type = type.toLowerCase().trim();
|
|
3654
|
-
|
|
3655
3079
|
if (type === 'application/x-www-form-urlencoded') {
|
|
3656
3080
|
this._data = this._data ? `${this._data}&${data}` : data;
|
|
3657
3081
|
} else {
|
|
@@ -3660,7 +3084,6 @@ RequestBase.prototype.send = function (data) {
|
|
|
3660
3084
|
} else {
|
|
3661
3085
|
this._data = data;
|
|
3662
3086
|
}
|
|
3663
|
-
|
|
3664
3087
|
if (!isObject_ || this._isHost(data)) {
|
|
3665
3088
|
return this;
|
|
3666
3089
|
}
|
|
@@ -3676,25 +3099,20 @@ RequestBase.prototype.sortQuery = function (sort) {
|
|
|
3676
3099
|
|
|
3677
3100
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
3678
3101
|
const query = this._query.join('&');
|
|
3679
|
-
|
|
3680
3102
|
if (query) {
|
|
3681
3103
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
3682
3104
|
}
|
|
3683
|
-
|
|
3684
3105
|
this._query.length = 0;
|
|
3685
3106
|
|
|
3686
3107
|
if (this._sort) {
|
|
3687
3108
|
const index = this.url.indexOf('?');
|
|
3688
|
-
|
|
3689
3109
|
if (index >= 0) {
|
|
3690
3110
|
const queryArray = this.url.slice(index + 1).split('&');
|
|
3691
|
-
|
|
3692
3111
|
if (typeof this._sort === 'function') {
|
|
3693
3112
|
queryArray.sort(this._sort);
|
|
3694
3113
|
} else {
|
|
3695
3114
|
queryArray.sort();
|
|
3696
3115
|
}
|
|
3697
|
-
|
|
3698
3116
|
this.url = this.url.slice(0, index) + '?' + queryArray.join('&');
|
|
3699
3117
|
}
|
|
3700
3118
|
}
|
|
@@ -3708,7 +3126,6 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3708
3126
|
if (this._aborted) {
|
|
3709
3127
|
return;
|
|
3710
3128
|
}
|
|
3711
|
-
|
|
3712
3129
|
const error = new Error(`${reason + timeout}ms exceeded`);
|
|
3713
3130
|
error.timeout = timeout;
|
|
3714
3131
|
error.code = 'ECONNABORTED';
|
|
@@ -3718,7 +3135,6 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3718
3135
|
this.abort();
|
|
3719
3136
|
this.callback(error);
|
|
3720
3137
|
};
|
|
3721
|
-
|
|
3722
3138
|
RequestBase.prototype._setTimeouts = function () {
|
|
3723
3139
|
const self = this;
|
|
3724
3140
|
|
|
@@ -3737,6 +3153,8 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
3737
3153
|
|
|
3738
3154
|
}).call(this)}).call(this,require('_process'))
|
|
3739
3155
|
},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
|
|
3156
|
+
|
|
3157
|
+
|
|
3740
3158
|
const utils = require('./utils');
|
|
3741
3159
|
|
|
3742
3160
|
module.exports = ResponseBase;
|
|
@@ -3748,34 +3166,38 @@ ResponseBase.prototype.get = function (field) {
|
|
|
3748
3166
|
};
|
|
3749
3167
|
|
|
3750
3168
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
3169
|
+
|
|
3751
3170
|
const ct = header['content-type'] || '';
|
|
3752
3171
|
this.type = utils.type(ct);
|
|
3753
|
-
const parameters = utils.params(ct);
|
|
3754
3172
|
|
|
3173
|
+
const parameters = utils.params(ct);
|
|
3755
3174
|
for (const key in parameters) {
|
|
3756
3175
|
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
3757
3176
|
}
|
|
3758
|
-
|
|
3759
3177
|
this.links = {};
|
|
3760
3178
|
|
|
3761
3179
|
try {
|
|
3762
3180
|
if (header.link) {
|
|
3763
3181
|
this.links = utils.parseLinks(header.link);
|
|
3764
3182
|
}
|
|
3765
|
-
} catch (err) {
|
|
3183
|
+
} catch (err) {
|
|
3184
|
+
}
|
|
3766
3185
|
};
|
|
3767
3186
|
|
|
3768
3187
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
3769
3188
|
const type = Math.trunc(status / 100);
|
|
3189
|
+
|
|
3770
3190
|
this.statusCode = status;
|
|
3771
3191
|
this.status = this.statusCode;
|
|
3772
3192
|
this.statusType = type;
|
|
3193
|
+
|
|
3773
3194
|
this.info = type === 1;
|
|
3774
3195
|
this.ok = type === 2;
|
|
3775
3196
|
this.redirect = type === 3;
|
|
3776
3197
|
this.clientError = type === 4;
|
|
3777
3198
|
this.serverError = type === 5;
|
|
3778
3199
|
this.error = type === 4 || type === 5 ? this.toError() : false;
|
|
3200
|
+
|
|
3779
3201
|
this.created = status === 201;
|
|
3780
3202
|
this.accepted = status === 202;
|
|
3781
3203
|
this.noContent = status === 204;
|
|
@@ -3788,31 +3210,29 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
3788
3210
|
};
|
|
3789
3211
|
|
|
3790
3212
|
},{"./utils":24}],24:[function(require,module,exports){
|
|
3213
|
+
|
|
3214
|
+
|
|
3791
3215
|
exports.type = string_ => string_.split(/ *; */).shift();
|
|
3792
3216
|
|
|
3793
3217
|
exports.params = value => {
|
|
3794
3218
|
const object = {};
|
|
3795
|
-
|
|
3796
3219
|
for (const string_ of value.split(/ *; */)) {
|
|
3797
3220
|
const parts = string_.split(/ *= */);
|
|
3798
3221
|
const key = parts.shift();
|
|
3799
3222
|
const value = parts.shift();
|
|
3800
3223
|
if (key && value) object[key] = value;
|
|
3801
3224
|
}
|
|
3802
|
-
|
|
3803
3225
|
return object;
|
|
3804
3226
|
};
|
|
3805
3227
|
|
|
3806
3228
|
exports.parseLinks = value => {
|
|
3807
3229
|
const object = {};
|
|
3808
|
-
|
|
3809
3230
|
for (const string_ of value.split(/ *, */)) {
|
|
3810
3231
|
const parts = string_.split(/ *; */);
|
|
3811
3232
|
const url = parts[0].slice(1, -1);
|
|
3812
3233
|
const rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
3813
3234
|
object[rel] = url;
|
|
3814
3235
|
}
|
|
3815
|
-
|
|
3816
3236
|
return object;
|
|
3817
3237
|
};
|
|
3818
3238
|
|
|
@@ -3821,12 +3241,10 @@ exports.cleanHeader = (header, changesOrigin) => {
|
|
|
3821
3241
|
delete header['content-length'];
|
|
3822
3242
|
delete header['transfer-encoding'];
|
|
3823
3243
|
delete header.host;
|
|
3824
|
-
|
|
3825
3244
|
if (changesOrigin) {
|
|
3826
3245
|
delete header.authorization;
|
|
3827
3246
|
delete header.cookie;
|
|
3828
3247
|
}
|
|
3829
|
-
|
|
3830
3248
|
return header;
|
|
3831
3249
|
};
|
|
3832
3250
|
|
|
@@ -3838,10 +3256,8 @@ exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
|
3838
3256
|
if (object == null) {
|
|
3839
3257
|
throw new TypeError('Cannot convert undefined or null to object');
|
|
3840
3258
|
}
|
|
3841
|
-
|
|
3842
3259
|
return Object.prototype.hasOwnProperty.call(new Object(object), property);
|
|
3843
3260
|
};
|
|
3844
|
-
|
|
3845
3261
|
exports.mixin = (target, source) => {
|
|
3846
3262
|
for (const key in source) {
|
|
3847
3263
|
if (exports.hasOwn(source, key)) {
|