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