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