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