proto-sudoku-wc 0.0.484 → 0.0.485

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -250,85 +250,78 @@ const createStore = (defaultState, shouldUpdate) => {
250
250
  return map;
251
251
  };
252
252
 
253
- var bind = function bind(fn, thisArg) {
253
+ function bind(fn, thisArg) {
254
254
  return function wrap() {
255
- var args = new Array(arguments.length);
256
- for (var i = 0; i < args.length; i++) {
257
- args[i] = arguments[i];
258
- }
259
- return fn.apply(thisArg, args);
255
+ return fn.apply(thisArg, arguments);
260
256
  };
261
- };
257
+ }
262
258
 
263
259
  // utils is a library of generic helper functions non-specific to axios
264
260
 
265
- var toString = Object.prototype.toString;
261
+ const {toString} = Object.prototype;
262
+ const {getPrototypeOf} = Object;
266
263
 
267
- // eslint-disable-next-line func-names
268
- var kindOf = (function(cache) {
269
- // eslint-disable-next-line func-names
270
- return function(thing) {
271
- var str = toString.call(thing);
264
+ const kindOf = (cache => thing => {
265
+ const str = toString.call(thing);
272
266
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
273
- };
274
267
  })(Object.create(null));
275
268
 
276
- function kindOfTest(type) {
269
+ const kindOfTest = (type) => {
277
270
  type = type.toLowerCase();
278
- return function isKindOf(thing) {
279
- return kindOf(thing) === type;
280
- };
281
- }
271
+ return (thing) => kindOf(thing) === type
272
+ };
273
+
274
+ const typeOfTest = type => thing => typeof thing === type;
282
275
 
283
276
  /**
284
277
  * Determine if a value is an Array
285
278
  *
286
279
  * @param {Object} val The value to test
280
+ *
287
281
  * @returns {boolean} True if value is an Array, otherwise false
288
282
  */
289
- function isArray(val) {
290
- return Array.isArray(val);
291
- }
283
+ const {isArray} = Array;
292
284
 
293
285
  /**
294
286
  * Determine if a value is undefined
295
287
  *
296
- * @param {Object} val The value to test
288
+ * @param {*} val The value to test
289
+ *
297
290
  * @returns {boolean} True if the value is undefined, otherwise false
298
291
  */
299
- function isUndefined(val) {
300
- return typeof val === 'undefined';
301
- }
292
+ const isUndefined = typeOfTest('undefined');
302
293
 
303
294
  /**
304
295
  * Determine if a value is a Buffer
305
296
  *
306
- * @param {Object} val The value to test
297
+ * @param {*} val The value to test
298
+ *
307
299
  * @returns {boolean} True if value is a Buffer, otherwise false
308
300
  */
309
301
  function isBuffer(val) {
310
302
  return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
311
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
303
+ && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
312
304
  }
313
305
 
314
306
  /**
315
307
  * Determine if a value is an ArrayBuffer
316
308
  *
317
- * @function
318
- * @param {Object} val The value to test
309
+ * @param {*} val The value to test
310
+ *
319
311
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
320
312
  */
321
- var isArrayBuffer = kindOfTest('ArrayBuffer');
313
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
322
314
 
323
315
 
324
316
  /**
325
317
  * Determine if a value is a view on an ArrayBuffer
326
318
  *
327
- * @param {Object} val The value to test
319
+ * @param {*} val The value to test
320
+ *
328
321
  * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
329
322
  */
330
323
  function isArrayBufferView(val) {
331
- var result;
324
+ let result;
332
325
  if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
333
326
  result = ArrayBuffer.isView(val);
334
327
  } else {
@@ -340,163 +333,141 @@ function isArrayBufferView(val) {
340
333
  /**
341
334
  * Determine if a value is a String
342
335
  *
343
- * @param {Object} val The value to test
336
+ * @param {*} val The value to test
337
+ *
344
338
  * @returns {boolean} True if value is a String, otherwise false
345
339
  */
346
- function isString(val) {
347
- return typeof val === 'string';
348
- }
340
+ const isString = typeOfTest('string');
341
+
342
+ /**
343
+ * Determine if a value is a Function
344
+ *
345
+ * @param {*} val The value to test
346
+ * @returns {boolean} True if value is a Function, otherwise false
347
+ */
348
+ const isFunction = typeOfTest('function');
349
349
 
350
350
  /**
351
351
  * Determine if a value is a Number
352
352
  *
353
- * @param {Object} val The value to test
353
+ * @param {*} val The value to test
354
+ *
354
355
  * @returns {boolean} True if value is a Number, otherwise false
355
356
  */
356
- function isNumber(val) {
357
- return typeof val === 'number';
358
- }
357
+ const isNumber = typeOfTest('number');
359
358
 
360
359
  /**
361
360
  * Determine if a value is an Object
362
361
  *
363
- * @param {Object} val The value to test
362
+ * @param {*} thing The value to test
363
+ *
364
364
  * @returns {boolean} True if value is an Object, otherwise false
365
365
  */
366
- function isObject(val) {
367
- return val !== null && typeof val === 'object';
368
- }
366
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
367
+
368
+ /**
369
+ * Determine if a value is a Boolean
370
+ *
371
+ * @param {*} thing The value to test
372
+ * @returns {boolean} True if value is a Boolean, otherwise false
373
+ */
374
+ const isBoolean = thing => thing === true || thing === false;
369
375
 
370
376
  /**
371
377
  * Determine if a value is a plain Object
372
378
  *
373
- * @param {Object} val The value to test
374
- * @return {boolean} True if value is a plain Object, otherwise false
379
+ * @param {*} val The value to test
380
+ *
381
+ * @returns {boolean} True if value is a plain Object, otherwise false
375
382
  */
376
- function isPlainObject(val) {
383
+ const isPlainObject = (val) => {
377
384
  if (kindOf(val) !== 'object') {
378
385
  return false;
379
386
  }
380
387
 
381
- var prototype = Object.getPrototypeOf(val);
388
+ const prototype = getPrototypeOf(val);
382
389
  return prototype === null || prototype === Object.prototype;
383
- }
390
+ };
384
391
 
385
392
  /**
386
393
  * Determine if a value is a Date
387
394
  *
388
- * @function
389
- * @param {Object} val The value to test
395
+ * @param {*} val The value to test
396
+ *
390
397
  * @returns {boolean} True if value is a Date, otherwise false
391
398
  */
392
- var isDate = kindOfTest('Date');
399
+ const isDate = kindOfTest('Date');
393
400
 
394
401
  /**
395
402
  * Determine if a value is a File
396
403
  *
397
- * @function
398
- * @param {Object} val The value to test
404
+ * @param {*} val The value to test
405
+ *
399
406
  * @returns {boolean} True if value is a File, otherwise false
400
407
  */
401
- var isFile = kindOfTest('File');
408
+ const isFile = kindOfTest('File');
402
409
 
403
410
  /**
404
411
  * Determine if a value is a Blob
405
412
  *
406
- * @function
407
- * @param {Object} val The value to test
413
+ * @param {*} val The value to test
414
+ *
408
415
  * @returns {boolean} True if value is a Blob, otherwise false
409
416
  */
410
- var isBlob = kindOfTest('Blob');
417
+ const isBlob = kindOfTest('Blob');
411
418
 
412
419
  /**
413
420
  * Determine if a value is a FileList
414
421
  *
415
- * @function
416
- * @param {Object} val The value to test
417
- * @returns {boolean} True if value is a File, otherwise false
418
- */
419
- var isFileList = kindOfTest('FileList');
420
-
421
- /**
422
- * Determine if a value is a Function
422
+ * @param {*} val The value to test
423
423
  *
424
- * @param {Object} val The value to test
425
- * @returns {boolean} True if value is a Function, otherwise false
424
+ * @returns {boolean} True if value is a File, otherwise false
426
425
  */
427
- function isFunction(val) {
428
- return toString.call(val) === '[object Function]';
429
- }
426
+ const isFileList = kindOfTest('FileList');
430
427
 
431
428
  /**
432
429
  * Determine if a value is a Stream
433
430
  *
434
- * @param {Object} val The value to test
431
+ * @param {*} val The value to test
432
+ *
435
433
  * @returns {boolean} True if value is a Stream, otherwise false
436
434
  */
437
- function isStream(val) {
438
- return isObject(val) && isFunction(val.pipe);
439
- }
435
+ const isStream = (val) => isObject(val) && isFunction(val.pipe);
440
436
 
441
437
  /**
442
438
  * Determine if a value is a FormData
443
439
  *
444
- * @param {Object} thing The value to test
440
+ * @param {*} thing The value to test
441
+ *
445
442
  * @returns {boolean} True if value is an FormData, otherwise false
446
443
  */
447
- function isFormData(thing) {
448
- var pattern = '[object FormData]';
444
+ const isFormData = (thing) => {
445
+ const pattern = '[object FormData]';
449
446
  return thing && (
450
447
  (typeof FormData === 'function' && thing instanceof FormData) ||
451
448
  toString.call(thing) === pattern ||
452
449
  (isFunction(thing.toString) && thing.toString() === pattern)
453
450
  );
454
- }
451
+ };
455
452
 
456
453
  /**
457
454
  * Determine if a value is a URLSearchParams object
458
- * @function
459
- * @param {Object} val The value to test
455
+ *
456
+ * @param {*} val The value to test
457
+ *
460
458
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
461
459
  */
462
- var isURLSearchParams = kindOfTest('URLSearchParams');
460
+ const isURLSearchParams = kindOfTest('URLSearchParams');
463
461
 
464
462
  /**
465
463
  * Trim excess whitespace off the beginning and end of a string
466
464
  *
467
465
  * @param {String} str The String to trim
468
- * @returns {String} The String freed of excess whitespace
469
- */
470
- function trim(str) {
471
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
472
- }
473
-
474
- /**
475
- * Determine if we're running in a standard browser environment
476
- *
477
- * This allows axios to run in a web worker, and react-native.
478
- * Both environments support XMLHttpRequest, but not fully standard globals.
479
- *
480
- * web workers:
481
- * typeof window -> undefined
482
- * typeof document -> undefined
483
466
  *
484
- * react-native:
485
- * navigator.product -> 'ReactNative'
486
- * nativescript
487
- * navigator.product -> 'NativeScript' or 'NS'
467
+ * @returns {String} The String freed of excess whitespace
488
468
  */
489
- function isStandardBrowserEnv() {
490
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
491
- navigator.product === 'NativeScript' ||
492
- navigator.product === 'NS')) {
493
- return false;
494
- }
495
- return (
496
- typeof window !== 'undefined' &&
497
- typeof document !== 'undefined'
498
- );
499
- }
469
+ const trim = (str) => str.trim ?
470
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
500
471
 
501
472
  /**
502
473
  * Iterate over an Array or an Object invoking a function for each item.
@@ -509,13 +480,19 @@ function isStandardBrowserEnv() {
509
480
  *
510
481
  * @param {Object|Array} obj The object to iterate
511
482
  * @param {Function} fn The callback to invoke for each item
483
+ *
484
+ * @param {Boolean} [allOwnKeys = false]
485
+ * @returns {void}
512
486
  */
513
- function forEach(obj, fn) {
487
+ function forEach(obj, fn, {allOwnKeys = false} = {}) {
514
488
  // Don't bother if no value provided
515
489
  if (obj === null || typeof obj === 'undefined') {
516
490
  return;
517
491
  }
518
492
 
493
+ let i;
494
+ let l;
495
+
519
496
  // Force an array if not already something iterable
520
497
  if (typeof obj !== 'object') {
521
498
  /*eslint no-param-reassign:0*/
@@ -524,15 +501,18 @@ function forEach(obj, fn) {
524
501
 
525
502
  if (isArray(obj)) {
526
503
  // Iterate over array values
527
- for (var i = 0, l = obj.length; i < l; i++) {
504
+ for (i = 0, l = obj.length; i < l; i++) {
528
505
  fn.call(null, obj[i], i, obj);
529
506
  }
530
507
  } else {
531
508
  // Iterate over object keys
532
- for (var key in obj) {
533
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
534
- fn.call(null, obj[key], key, obj);
535
- }
509
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
510
+ const len = keys.length;
511
+ let key;
512
+
513
+ for (i = 0; i < len; i++) {
514
+ key = keys[i];
515
+ fn.call(null, obj[key], key, obj);
536
516
  }
537
517
  }
538
518
  }
@@ -552,11 +532,12 @@ function forEach(obj, fn) {
552
532
  * ```
553
533
  *
554
534
  * @param {Object} obj1 Object to merge
535
+ *
555
536
  * @returns {Object} Result of all merge properties
556
537
  */
557
538
  function merge(/* obj1, obj2, obj3, ... */) {
558
- var result = {};
559
- function assignValue(val, key) {
539
+ const result = {};
540
+ const assignValue = (val, key) => {
560
541
  if (isPlainObject(result[key]) && isPlainObject(val)) {
561
542
  result[key] = merge(result[key], val);
562
543
  } else if (isPlainObject(val)) {
@@ -566,10 +547,10 @@ function merge(/* obj1, obj2, obj3, ... */) {
566
547
  } else {
567
548
  result[key] = val;
568
549
  }
569
- }
550
+ };
570
551
 
571
- for (var i = 0, l = arguments.length; i < l; i++) {
572
- forEach(arguments[i], assignValue);
552
+ for (let i = 0, l = arguments.length; i < l; i++) {
553
+ arguments[i] && forEach(arguments[i], assignValue);
573
554
  }
574
555
  return result;
575
556
  }
@@ -580,31 +561,34 @@ function merge(/* obj1, obj2, obj3, ... */) {
580
561
  * @param {Object} a The object to be extended
581
562
  * @param {Object} b The object to copy properties from
582
563
  * @param {Object} thisArg The object to bind function to
583
- * @return {Object} The resulting value of object a
564
+ *
565
+ * @param {Boolean} [allOwnKeys]
566
+ * @returns {Object} The resulting value of object a
584
567
  */
585
- function extend(a, b, thisArg) {
586
- forEach(b, function assignValue(val, key) {
587
- if (thisArg && typeof val === 'function') {
568
+ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
569
+ forEach(b, (val, key) => {
570
+ if (thisArg && isFunction(val)) {
588
571
  a[key] = bind(val, thisArg);
589
572
  } else {
590
573
  a[key] = val;
591
574
  }
592
- });
575
+ }, {allOwnKeys});
593
576
  return a;
594
- }
577
+ };
595
578
 
596
579
  /**
597
580
  * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
598
581
  *
599
582
  * @param {string} content with BOM
600
- * @return {string} content value without BOM
583
+ *
584
+ * @returns {string} content value without BOM
601
585
  */
602
- function stripBOM(content) {
586
+ const stripBOM = (content) => {
603
587
  if (content.charCodeAt(0) === 0xFEFF) {
604
588
  content = content.slice(1);
605
589
  }
606
590
  return content;
607
- }
591
+ };
608
592
 
609
593
  /**
610
594
  * Inherit the prototype methods from one constructor into another
@@ -612,246 +596,274 @@ function stripBOM(content) {
612
596
  * @param {function} superConstructor
613
597
  * @param {object} [props]
614
598
  * @param {object} [descriptors]
599
+ *
600
+ * @returns {void}
615
601
  */
616
-
617
- function inherits(constructor, superConstructor, props, descriptors) {
602
+ const inherits = (constructor, superConstructor, props, descriptors) => {
618
603
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
619
604
  constructor.prototype.constructor = constructor;
605
+ Object.defineProperty(constructor, 'super', {
606
+ value: superConstructor.prototype
607
+ });
620
608
  props && Object.assign(constructor.prototype, props);
621
- }
609
+ };
622
610
 
623
611
  /**
624
612
  * Resolve object with deep prototype chain to a flat object
625
613
  * @param {Object} sourceObj source object
626
614
  * @param {Object} [destObj]
627
- * @param {Function} [filter]
615
+ * @param {Function|Boolean} [filter]
616
+ * @param {Function} [propFilter]
617
+ *
628
618
  * @returns {Object}
629
619
  */
630
-
631
- function toFlatObject(sourceObj, destObj, filter) {
632
- var props;
633
- var i;
634
- var prop;
635
- var merged = {};
620
+ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
621
+ let props;
622
+ let i;
623
+ let prop;
624
+ const merged = {};
636
625
 
637
626
  destObj = destObj || {};
627
+ // eslint-disable-next-line no-eq-null,eqeqeq
628
+ if (sourceObj == null) return destObj;
638
629
 
639
630
  do {
640
631
  props = Object.getOwnPropertyNames(sourceObj);
641
632
  i = props.length;
642
633
  while (i-- > 0) {
643
634
  prop = props[i];
644
- if (!merged[prop]) {
635
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
645
636
  destObj[prop] = sourceObj[prop];
646
637
  merged[prop] = true;
647
638
  }
648
639
  }
649
- sourceObj = Object.getPrototypeOf(sourceObj);
640
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
650
641
  } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
651
642
 
652
643
  return destObj;
653
- }
644
+ };
654
645
 
655
- /*
656
- * determines whether a string ends with the characters of a specified string
646
+ /**
647
+ * Determines whether a string ends with the characters of a specified string
648
+ *
657
649
  * @param {String} str
658
650
  * @param {String} searchString
659
651
  * @param {Number} [position= 0]
652
+ *
660
653
  * @returns {boolean}
661
654
  */
662
- function endsWith(str, searchString, position) {
655
+ const endsWith = (str, searchString, position) => {
663
656
  str = String(str);
664
657
  if (position === undefined || position > str.length) {
665
658
  position = str.length;
666
659
  }
667
660
  position -= searchString.length;
668
- var lastIndex = str.indexOf(searchString, position);
661
+ const lastIndex = str.indexOf(searchString, position);
669
662
  return lastIndex !== -1 && lastIndex === position;
670
- }
663
+ };
671
664
 
672
665
 
673
666
  /**
674
- * Returns new array from array like object
667
+ * Returns new array from array like object or null if failed
668
+ *
675
669
  * @param {*} [thing]
676
- * @returns {Array}
670
+ *
671
+ * @returns {?Array}
677
672
  */
678
- function toArray(thing) {
673
+ const toArray = (thing) => {
679
674
  if (!thing) return null;
680
- var i = thing.length;
681
- if (isUndefined(i)) return null;
682
- var arr = new Array(i);
675
+ if (isArray(thing)) return thing;
676
+ let i = thing.length;
677
+ if (!isNumber(i)) return null;
678
+ const arr = new Array(i);
683
679
  while (i-- > 0) {
684
680
  arr[i] = thing[i];
685
681
  }
686
682
  return arr;
687
- }
683
+ };
688
684
 
685
+ /**
686
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
687
+ * thing passed in is an instance of Uint8Array
688
+ *
689
+ * @param {TypedArray}
690
+ *
691
+ * @returns {Array}
692
+ */
689
693
  // eslint-disable-next-line func-names
690
- var isTypedArray = (function(TypedArray) {
694
+ const isTypedArray = (TypedArray => {
691
695
  // eslint-disable-next-line func-names
692
- return function(thing) {
696
+ return thing => {
693
697
  return TypedArray && thing instanceof TypedArray;
694
698
  };
695
- })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
696
-
697
- var utils = {
698
- isArray: isArray,
699
- isArrayBuffer: isArrayBuffer,
700
- isBuffer: isBuffer,
701
- isFormData: isFormData,
702
- isArrayBufferView: isArrayBufferView,
703
- isString: isString,
704
- isNumber: isNumber,
705
- isObject: isObject,
706
- isPlainObject: isPlainObject,
707
- isUndefined: isUndefined,
708
- isDate: isDate,
709
- isFile: isFile,
710
- isBlob: isBlob,
711
- isFunction: isFunction,
712
- isStream: isStream,
713
- isURLSearchParams: isURLSearchParams,
714
- isStandardBrowserEnv: isStandardBrowserEnv,
715
- forEach: forEach,
716
- merge: merge,
717
- extend: extend,
718
- trim: trim,
719
- stripBOM: stripBOM,
720
- inherits: inherits,
721
- toFlatObject: toFlatObject,
722
- kindOf: kindOf,
723
- kindOfTest: kindOfTest,
724
- endsWith: endsWith,
725
- toArray: toArray,
726
- isTypedArray: isTypedArray,
727
- isFileList: isFileList
728
- };
729
-
730
- function encode(val) {
731
- return encodeURIComponent(val).
732
- replace(/%3A/gi, ':').
733
- replace(/%24/g, '$').
734
- replace(/%2C/gi, ',').
735
- replace(/%20/g, '+').
736
- replace(/%5B/gi, '[').
737
- replace(/%5D/gi, ']');
738
- }
699
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
739
700
 
740
701
  /**
741
- * Build a URL by appending params to the end
702
+ * For each entry in the object, call the function with the key and value.
742
703
  *
743
- * @param {string} url The base of the url (e.g., http://www.google.com)
744
- * @param {object} [params] The params to be appended
745
- * @returns {string} The formatted url
704
+ * @param {Object<any, any>} obj - The object to iterate over.
705
+ * @param {Function} fn - The function to call for each entry.
706
+ *
707
+ * @returns {void}
746
708
  */
747
- var buildURL = function buildURL(url, params, paramsSerializer) {
748
- /*eslint no-param-reassign:0*/
749
- if (!params) {
750
- return url;
751
- }
709
+ const forEachEntry = (obj, fn) => {
710
+ const generator = obj && obj[Symbol.iterator];
752
711
 
753
- var serializedParams;
754
- if (paramsSerializer) {
755
- serializedParams = paramsSerializer(params);
756
- } else if (utils.isURLSearchParams(params)) {
757
- serializedParams = params.toString();
758
- } else {
759
- var parts = [];
712
+ const iterator = generator.call(obj);
760
713
 
761
- utils.forEach(params, function serialize(val, key) {
762
- if (val === null || typeof val === 'undefined') {
763
- return;
764
- }
714
+ let result;
765
715
 
766
- if (utils.isArray(val)) {
767
- key = key + '[]';
768
- } else {
769
- val = [val];
770
- }
716
+ while ((result = iterator.next()) && !result.done) {
717
+ const pair = result.value;
718
+ fn.call(obj, pair[0], pair[1]);
719
+ }
720
+ };
771
721
 
772
- utils.forEach(val, function parseValue(v) {
773
- if (utils.isDate(v)) {
774
- v = v.toISOString();
775
- } else if (utils.isObject(v)) {
776
- v = JSON.stringify(v);
777
- }
778
- parts.push(encode(key) + '=' + encode(v));
779
- });
780
- });
722
+ /**
723
+ * It takes a regular expression and a string, and returns an array of all the matches
724
+ *
725
+ * @param {string} regExp - The regular expression to match against.
726
+ * @param {string} str - The string to search.
727
+ *
728
+ * @returns {Array<boolean>}
729
+ */
730
+ const matchAll = (regExp, str) => {
731
+ let matches;
732
+ const arr = [];
781
733
 
782
- serializedParams = parts.join('&');
734
+ while ((matches = regExp.exec(str)) !== null) {
735
+ arr.push(matches);
783
736
  }
784
737
 
785
- if (serializedParams) {
786
- var hashmarkIndex = url.indexOf('#');
787
- if (hashmarkIndex !== -1) {
788
- url = url.slice(0, hashmarkIndex);
789
- }
738
+ return arr;
739
+ };
790
740
 
791
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
792
- }
741
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
742
+ const isHTMLForm = kindOfTest('HTMLFormElement');
793
743
 
794
- return url;
744
+ const toCamelCase = str => {
745
+ return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,
746
+ function replacer(m, p1, p2) {
747
+ return p1.toUpperCase() + p2;
748
+ }
749
+ );
795
750
  };
796
751
 
797
- function InterceptorManager() {
798
- this.handlers = [];
799
- }
752
+ /* Creating a function that will check if an object has a property. */
753
+ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
800
754
 
801
755
  /**
802
- * Add a new interceptor to the stack
756
+ * Determine if a value is a RegExp object
803
757
  *
804
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
805
- * @param {Function} rejected The function to handle `reject` for a `Promise`
758
+ * @param {*} val The value to test
806
759
  *
807
- * @return {Number} An ID used to remove interceptor later
760
+ * @returns {boolean} True if value is a RegExp object, otherwise false
808
761
  */
809
- InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
810
- this.handlers.push({
811
- fulfilled: fulfilled,
812
- rejected: rejected,
813
- synchronous: options ? options.synchronous : false,
814
- runWhen: options ? options.runWhen : null
762
+ const isRegExp = kindOfTest('RegExp');
763
+
764
+ const reduceDescriptors = (obj, reducer) => {
765
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
766
+ const reducedDescriptors = {};
767
+
768
+ forEach(descriptors, (descriptor, name) => {
769
+ if (reducer(descriptor, name, obj) !== false) {
770
+ reducedDescriptors[name] = descriptor;
771
+ }
815
772
  });
816
- return this.handlers.length - 1;
817
- };
818
773
 
819
- /**
820
- * Remove an interceptor from the stack
821
- *
822
- * @param {Number} id The ID that was returned by `use`
823
- */
824
- InterceptorManager.prototype.eject = function eject(id) {
825
- if (this.handlers[id]) {
826
- this.handlers[id] = null;
827
- }
774
+ Object.defineProperties(obj, reducedDescriptors);
828
775
  };
829
776
 
830
777
  /**
831
- * Iterate over all the registered interceptors
832
- *
833
- * This method is particularly useful for skipping over any
834
- * interceptors that may have become `null` calling `eject`.
835
- *
836
- * @param {Function} fn The function to call for each interceptor
778
+ * Makes all methods read-only
779
+ * @param {Object} obj
837
780
  */
838
- InterceptorManager.prototype.forEach = function forEach(fn) {
839
- utils.forEach(this.handlers, function forEachHandler(h) {
840
- if (h !== null) {
841
- fn(h);
781
+
782
+ const freezeMethods = (obj) => {
783
+ reduceDescriptors(obj, (descriptor, name) => {
784
+ const value = obj[name];
785
+
786
+ if (!isFunction(value)) return;
787
+
788
+ descriptor.enumerable = false;
789
+
790
+ if ('writable' in descriptor) {
791
+ descriptor.writable = false;
792
+ return;
793
+ }
794
+
795
+ if (!descriptor.set) {
796
+ descriptor.set = () => {
797
+ throw Error('Can not read-only method \'' + name + '\'');
798
+ };
842
799
  }
843
800
  });
844
801
  };
845
802
 
846
- var InterceptorManager_1 = InterceptorManager;
803
+ const toObjectSet = (arrayOrString, delimiter) => {
804
+ const obj = {};
847
805
 
848
- var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
849
- utils.forEach(headers, function processHeader(value, name) {
850
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
851
- headers[normalizedName] = value;
852
- delete headers[name];
853
- }
854
- });
806
+ const define = (arr) => {
807
+ arr.forEach(value => {
808
+ obj[value] = true;
809
+ });
810
+ };
811
+
812
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
813
+
814
+ return obj;
815
+ };
816
+
817
+ const noop = () => {};
818
+
819
+ const toFiniteNumber = (value, defaultValue) => {
820
+ value = +value;
821
+ return Number.isFinite(value) ? value : defaultValue;
822
+ };
823
+
824
+ const utils = {
825
+ isArray,
826
+ isArrayBuffer,
827
+ isBuffer,
828
+ isFormData,
829
+ isArrayBufferView,
830
+ isString,
831
+ isNumber,
832
+ isBoolean,
833
+ isObject,
834
+ isPlainObject,
835
+ isUndefined,
836
+ isDate,
837
+ isFile,
838
+ isBlob,
839
+ isRegExp,
840
+ isFunction,
841
+ isStream,
842
+ isURLSearchParams,
843
+ isTypedArray,
844
+ isFileList,
845
+ forEach,
846
+ merge,
847
+ extend,
848
+ trim,
849
+ stripBOM,
850
+ inherits,
851
+ toFlatObject,
852
+ kindOf,
853
+ kindOfTest,
854
+ endsWith,
855
+ toArray,
856
+ forEachEntry,
857
+ matchAll,
858
+ isHTMLForm,
859
+ hasOwnProperty,
860
+ hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
861
+ reduceDescriptors,
862
+ freezeMethods,
863
+ toObjectSet,
864
+ toCamelCase,
865
+ noop,
866
+ toFiniteNumber
855
867
  };
856
868
 
857
869
  /**
@@ -862,10 +874,18 @@ var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName)
862
874
  * @param {Object} [config] The config.
863
875
  * @param {Object} [request] The request.
864
876
  * @param {Object} [response] The response.
877
+ *
865
878
  * @returns {Error} The created error.
866
879
  */
867
880
  function AxiosError(message, code, config, request, response) {
868
881
  Error.call(this);
882
+
883
+ if (Error.captureStackTrace) {
884
+ Error.captureStackTrace(this, this.constructor);
885
+ } else {
886
+ this.stack = (new Error()).stack;
887
+ }
888
+
869
889
  this.message = message;
870
890
  this.name = 'AxiosError';
871
891
  code && (this.code = code);
@@ -896,8 +916,8 @@ utils.inherits(AxiosError, Error, {
896
916
  }
897
917
  });
898
918
 
899
- var prototype = AxiosError.prototype;
900
- var descriptors = {};
919
+ const prototype$1 = AxiosError.prototype;
920
+ const descriptors = {};
901
921
 
902
922
  [
903
923
  'ERR_BAD_OPTION_VALUE',
@@ -909,25 +929,31 @@ var descriptors = {};
909
929
  'ERR_DEPRECATED',
910
930
  'ERR_BAD_RESPONSE',
911
931
  'ERR_BAD_REQUEST',
912
- 'ERR_CANCELED'
932
+ 'ERR_CANCELED',
933
+ 'ERR_NOT_SUPPORT',
934
+ 'ERR_INVALID_URL'
913
935
  // eslint-disable-next-line func-names
914
- ].forEach(function(code) {
936
+ ].forEach(code => {
915
937
  descriptors[code] = {value: code};
916
938
  });
917
939
 
918
940
  Object.defineProperties(AxiosError, descriptors);
919
- Object.defineProperty(prototype, 'isAxiosError', {value: true});
941
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
920
942
 
921
943
  // eslint-disable-next-line func-names
922
- AxiosError.from = function(error, code, config, request, response, customProps) {
923
- var axiosError = Object.create(prototype);
944
+ AxiosError.from = (error, code, config, request, response, customProps) => {
945
+ const axiosError = Object.create(prototype$1);
924
946
 
925
947
  utils.toFlatObject(error, axiosError, function filter(obj) {
926
948
  return obj !== Error.prototype;
949
+ }, prop => {
950
+ return prop !== 'isAxiosError';
927
951
  });
928
952
 
929
953
  AxiosError.call(axiosError, error.message, code, config, request, response);
930
954
 
955
+ axiosError.cause = error;
956
+
931
957
  axiosError.name = error.name;
932
958
 
933
959
  customProps && Object.assign(axiosError, customProps);
@@ -935,26 +961,127 @@ AxiosError.from = function(error, code, config, request, response, customProps)
935
961
  return axiosError;
936
962
  };
937
963
 
938
- var AxiosError_1 = AxiosError;
964
+ /* eslint-env browser */
965
+ var browser = typeof self == 'object' ? self.FormData : window.FormData;
939
966
 
940
- var transitional = {
941
- silentJSONParsing: true,
942
- forcedJSONParsing: true,
943
- clarifyTimeoutError: false
944
- };
967
+ /**
968
+ * Determines if the given thing is a array or js object.
969
+ *
970
+ * @param {string} thing - The object or array to be visited.
971
+ *
972
+ * @returns {boolean}
973
+ */
974
+ function isVisitable(thing) {
975
+ return utils.isPlainObject(thing) || utils.isArray(thing);
976
+ }
977
+
978
+ /**
979
+ * It removes the brackets from the end of a string
980
+ *
981
+ * @param {string} key - The key of the parameter.
982
+ *
983
+ * @returns {string} the key without the brackets.
984
+ */
985
+ function removeBrackets(key) {
986
+ return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
987
+ }
988
+
989
+ /**
990
+ * It takes a path, a key, and a boolean, and returns a string
991
+ *
992
+ * @param {string} path - The path to the current key.
993
+ * @param {string} key - The key of the current object being iterated over.
994
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
995
+ *
996
+ * @returns {string} The path to the current key.
997
+ */
998
+ function renderKey(path, key, dots) {
999
+ if (!path) return key;
1000
+ return path.concat(key).map(function each(token, i) {
1001
+ // eslint-disable-next-line no-param-reassign
1002
+ token = removeBrackets(token);
1003
+ return !dots && i ? '[' + token + ']' : token;
1004
+ }).join(dots ? '.' : '');
1005
+ }
1006
+
1007
+ /**
1008
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
1009
+ *
1010
+ * @param {Array<any>} arr - The array to check
1011
+ *
1012
+ * @returns {boolean}
1013
+ */
1014
+ function isFlatArray(arr) {
1015
+ return utils.isArray(arr) && !arr.some(isVisitable);
1016
+ }
1017
+
1018
+ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
1019
+ return /^is[A-Z]/.test(prop);
1020
+ });
1021
+
1022
+ /**
1023
+ * If the thing is a FormData object, return true, otherwise return false.
1024
+ *
1025
+ * @param {unknown} thing - The thing to check.
1026
+ *
1027
+ * @returns {boolean}
1028
+ */
1029
+ function isSpecCompliant(thing) {
1030
+ return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
1031
+ }
945
1032
 
946
1033
  /**
947
1034
  * Convert a data object to FormData
1035
+ *
948
1036
  * @param {Object} obj
949
1037
  * @param {?Object} [formData]
1038
+ * @param {?Object} [options]
1039
+ * @param {Function} [options.visitor]
1040
+ * @param {Boolean} [options.metaTokens = true]
1041
+ * @param {Boolean} [options.dots = false]
1042
+ * @param {?Boolean} [options.indexes = false]
1043
+ *
950
1044
  * @returns {Object}
951
1045
  **/
952
1046
 
953
- function toFormData(obj, formData) {
1047
+ /**
1048
+ * It converts an object into a FormData object
1049
+ *
1050
+ * @param {Object<any, any>} obj - The object to convert to form data.
1051
+ * @param {string} formData - The FormData object to append to.
1052
+ * @param {Object<string, any>} options
1053
+ *
1054
+ * @returns
1055
+ */
1056
+ function toFormData(obj, formData, options) {
1057
+ if (!utils.isObject(obj)) {
1058
+ throw new TypeError('target must be an object');
1059
+ }
1060
+
954
1061
  // eslint-disable-next-line no-param-reassign
955
- formData = formData || new FormData();
1062
+ formData = formData || new (browser || FormData)();
956
1063
 
957
- var stack = [];
1064
+ // eslint-disable-next-line no-param-reassign
1065
+ options = utils.toFlatObject(options, {
1066
+ metaTokens: true,
1067
+ dots: false,
1068
+ indexes: false
1069
+ }, false, function defined(option, source) {
1070
+ // eslint-disable-next-line no-eq-null,eqeqeq
1071
+ return !utils.isUndefined(source[option]);
1072
+ });
1073
+
1074
+ const metaTokens = options.metaTokens;
1075
+ // eslint-disable-next-line no-use-before-define
1076
+ const visitor = options.visitor || defaultVisitor;
1077
+ const dots = options.dots;
1078
+ const indexes = options.indexes;
1079
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1080
+ const useBlob = _Blob && isSpecCompliant(formData);
1081
+
1082
+ if (!utils.isFunction(visitor)) {
1083
+ throw new TypeError('visitor must be a function');
1084
+ }
958
1085
 
959
1086
  function convertValue(value) {
960
1087
  if (value === null) return '';
@@ -963,46 +1090,95 @@ function toFormData(obj, formData) {
963
1090
  return value.toISOString();
964
1091
  }
965
1092
 
1093
+ if (!useBlob && utils.isBlob(value)) {
1094
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1095
+ }
1096
+
966
1097
  if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
967
- return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1098
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
968
1099
  }
969
1100
 
970
1101
  return value;
971
1102
  }
972
1103
 
973
- function build(data, parentKey) {
974
- if (utils.isPlainObject(data) || utils.isArray(data)) {
975
- if (stack.indexOf(data) !== -1) {
976
- throw Error('Circular reference detected in ' + parentKey);
977
- }
1104
+ /**
1105
+ * Default visitor.
1106
+ *
1107
+ * @param {*} value
1108
+ * @param {String|Number} key
1109
+ * @param {Array<String|Number>} path
1110
+ * @this {FormData}
1111
+ *
1112
+ * @returns {boolean} return true to visit the each prop of the value recursively
1113
+ */
1114
+ function defaultVisitor(value, key, path) {
1115
+ let arr = value;
1116
+
1117
+ if (value && !path && typeof value === 'object') {
1118
+ if (utils.endsWith(key, '{}')) {
1119
+ // eslint-disable-next-line no-param-reassign
1120
+ key = metaTokens ? key : key.slice(0, -2);
1121
+ // eslint-disable-next-line no-param-reassign
1122
+ value = JSON.stringify(value);
1123
+ } else if (
1124
+ (utils.isArray(value) && isFlatArray(value)) ||
1125
+ (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
1126
+ )) {
1127
+ // eslint-disable-next-line no-param-reassign
1128
+ key = removeBrackets(key);
1129
+
1130
+ arr.forEach(function each(el, index) {
1131
+ !utils.isUndefined(el) && formData.append(
1132
+ // eslint-disable-next-line no-nested-ternary
1133
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1134
+ convertValue(el)
1135
+ );
1136
+ });
1137
+ return false;
1138
+ }
1139
+ }
978
1140
 
979
- stack.push(data);
980
-
981
- utils.forEach(data, function each(value, key) {
982
- if (utils.isUndefined(value)) return;
983
- var fullKey = parentKey ? parentKey + '.' + key : key;
984
- var arr;
985
-
986
- if (value && !parentKey && typeof value === 'object') {
987
- if (utils.endsWith(key, '{}')) {
988
- // eslint-disable-next-line no-param-reassign
989
- value = JSON.stringify(value);
990
- } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
991
- // eslint-disable-next-line func-names
992
- arr.forEach(function(el) {
993
- !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
994
- });
995
- return;
996
- }
997
- }
1141
+ if (isVisitable(value)) {
1142
+ return true;
1143
+ }
998
1144
 
999
- build(value, fullKey);
1000
- });
1145
+ formData.append(renderKey(path, key, dots), convertValue(value));
1001
1146
 
1002
- stack.pop();
1003
- } else {
1004
- formData.append(parentKey, convertValue(data));
1147
+ return false;
1148
+ }
1149
+
1150
+ const stack = [];
1151
+
1152
+ const exposedHelpers = Object.assign(predicates, {
1153
+ defaultVisitor,
1154
+ convertValue,
1155
+ isVisitable
1156
+ });
1157
+
1158
+ function build(value, path) {
1159
+ if (utils.isUndefined(value)) return;
1160
+
1161
+ if (stack.indexOf(value) !== -1) {
1162
+ throw Error('Circular reference detected in ' + path.join('.'));
1005
1163
  }
1164
+
1165
+ stack.push(value);
1166
+
1167
+ utils.forEach(value, function each(el, key) {
1168
+ const result = !utils.isUndefined(el) && visitor.call(
1169
+ formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
1170
+ );
1171
+
1172
+ if (result === true) {
1173
+ build(el, path ? path.concat(key) : [key]);
1174
+ }
1175
+ });
1176
+
1177
+ stack.pop();
1178
+ }
1179
+
1180
+ if (!utils.isObject(obj)) {
1181
+ throw new TypeError('data must be an object');
1006
1182
  }
1007
1183
 
1008
1184
  build(obj);
@@ -1010,7 +1186,323 @@ function toFormData(obj, formData) {
1010
1186
  return formData;
1011
1187
  }
1012
1188
 
1013
- var toFormData_1 = toFormData;
1189
+ /**
1190
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1191
+ * their percent-encoded equivalents
1192
+ *
1193
+ * @param {string} str - The string to encode.
1194
+ *
1195
+ * @returns {string} The encoded string.
1196
+ */
1197
+ function encode$1(str) {
1198
+ const charMap = {
1199
+ '!': '%21',
1200
+ "'": '%27',
1201
+ '(': '%28',
1202
+ ')': '%29',
1203
+ '~': '%7E',
1204
+ '%20': '+',
1205
+ '%00': '\x00'
1206
+ };
1207
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1208
+ return charMap[match];
1209
+ });
1210
+ }
1211
+
1212
+ /**
1213
+ * It takes a params object and converts it to a FormData object
1214
+ *
1215
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1216
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1217
+ *
1218
+ * @returns {void}
1219
+ */
1220
+ function AxiosURLSearchParams(params, options) {
1221
+ this._pairs = [];
1222
+
1223
+ params && toFormData(params, this, options);
1224
+ }
1225
+
1226
+ const prototype = AxiosURLSearchParams.prototype;
1227
+
1228
+ prototype.append = function append(name, value) {
1229
+ this._pairs.push([name, value]);
1230
+ };
1231
+
1232
+ prototype.toString = function toString(encoder) {
1233
+ const _encode = encoder ? function(value) {
1234
+ return encoder.call(this, value, encode$1);
1235
+ } : encode$1;
1236
+
1237
+ return this._pairs.map(function each(pair) {
1238
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1239
+ }, '').join('&');
1240
+ };
1241
+
1242
+ /**
1243
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1244
+ * URI encoded counterparts
1245
+ *
1246
+ * @param {string} val The value to be encoded.
1247
+ *
1248
+ * @returns {string} The encoded value.
1249
+ */
1250
+ function encode(val) {
1251
+ return encodeURIComponent(val).
1252
+ replace(/%3A/gi, ':').
1253
+ replace(/%24/g, '$').
1254
+ replace(/%2C/gi, ',').
1255
+ replace(/%20/g, '+').
1256
+ replace(/%5B/gi, '[').
1257
+ replace(/%5D/gi, ']');
1258
+ }
1259
+
1260
+ /**
1261
+ * Build a URL by appending params to the end
1262
+ *
1263
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1264
+ * @param {object} [params] The params to be appended
1265
+ * @param {?object} options
1266
+ *
1267
+ * @returns {string} The formatted url
1268
+ */
1269
+ function buildURL(url, params, options) {
1270
+ /*eslint no-param-reassign:0*/
1271
+ if (!params) {
1272
+ return url;
1273
+ }
1274
+
1275
+ const hashmarkIndex = url.indexOf('#');
1276
+
1277
+ if (hashmarkIndex !== -1) {
1278
+ url = url.slice(0, hashmarkIndex);
1279
+ }
1280
+
1281
+ const _encode = options && options.encode || encode;
1282
+
1283
+ const serializerParams = utils.isURLSearchParams(params) ?
1284
+ params.toString() :
1285
+ new AxiosURLSearchParams(params, options).toString(_encode);
1286
+
1287
+ if (serializerParams) {
1288
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializerParams;
1289
+ }
1290
+
1291
+ return url;
1292
+ }
1293
+
1294
+ class InterceptorManager {
1295
+ constructor() {
1296
+ this.handlers = [];
1297
+ }
1298
+
1299
+ /**
1300
+ * Add a new interceptor to the stack
1301
+ *
1302
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1303
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1304
+ *
1305
+ * @return {Number} An ID used to remove interceptor later
1306
+ */
1307
+ use(fulfilled, rejected, options) {
1308
+ this.handlers.push({
1309
+ fulfilled,
1310
+ rejected,
1311
+ synchronous: options ? options.synchronous : false,
1312
+ runWhen: options ? options.runWhen : null
1313
+ });
1314
+ return this.handlers.length - 1;
1315
+ }
1316
+
1317
+ /**
1318
+ * Remove an interceptor from the stack
1319
+ *
1320
+ * @param {Number} id The ID that was returned by `use`
1321
+ *
1322
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1323
+ */
1324
+ eject(id) {
1325
+ if (this.handlers[id]) {
1326
+ this.handlers[id] = null;
1327
+ }
1328
+ }
1329
+
1330
+ /**
1331
+ * Clear all interceptors from the stack
1332
+ *
1333
+ * @returns {void}
1334
+ */
1335
+ clear() {
1336
+ if (this.handlers) {
1337
+ this.handlers = [];
1338
+ }
1339
+ }
1340
+
1341
+ /**
1342
+ * Iterate over all the registered interceptors
1343
+ *
1344
+ * This method is particularly useful for skipping over any
1345
+ * interceptors that may have become `null` calling `eject`.
1346
+ *
1347
+ * @param {Function} fn The function to call for each interceptor
1348
+ *
1349
+ * @returns {void}
1350
+ */
1351
+ forEach(fn) {
1352
+ utils.forEach(this.handlers, function forEachHandler(h) {
1353
+ if (h !== null) {
1354
+ fn(h);
1355
+ }
1356
+ });
1357
+ }
1358
+ }
1359
+
1360
+ const transitionalDefaults = {
1361
+ silentJSONParsing: true,
1362
+ forcedJSONParsing: true,
1363
+ clarifyTimeoutError: false
1364
+ };
1365
+
1366
+ const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1367
+
1368
+ const FormData$1 = FormData;
1369
+
1370
+ /**
1371
+ * Determine if we're running in a standard browser environment
1372
+ *
1373
+ * This allows axios to run in a web worker, and react-native.
1374
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1375
+ *
1376
+ * web workers:
1377
+ * typeof window -> undefined
1378
+ * typeof document -> undefined
1379
+ *
1380
+ * react-native:
1381
+ * navigator.product -> 'ReactNative'
1382
+ * nativescript
1383
+ * navigator.product -> 'NativeScript' or 'NS'
1384
+ *
1385
+ * @returns {boolean}
1386
+ */
1387
+ const isStandardBrowserEnv = (() => {
1388
+ let product;
1389
+ if (typeof navigator !== 'undefined' && (
1390
+ (product = navigator.product) === 'ReactNative' ||
1391
+ product === 'NativeScript' ||
1392
+ product === 'NS')
1393
+ ) {
1394
+ return false;
1395
+ }
1396
+
1397
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
1398
+ })();
1399
+
1400
+ const platform = {
1401
+ isBrowser: true,
1402
+ classes: {
1403
+ URLSearchParams: URLSearchParams$1,
1404
+ FormData: FormData$1,
1405
+ Blob
1406
+ },
1407
+ isStandardBrowserEnv,
1408
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1409
+ };
1410
+
1411
+ function toURLEncodedForm(data, options) {
1412
+ return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1413
+ visitor: function(value, key, path, helpers) {
1414
+
1415
+ return helpers.defaultVisitor.apply(this, arguments);
1416
+ }
1417
+ }, options));
1418
+ }
1419
+
1420
+ /**
1421
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1422
+ *
1423
+ * @param {string} name - The name of the property to get.
1424
+ *
1425
+ * @returns An array of strings.
1426
+ */
1427
+ function parsePropPath(name) {
1428
+ // foo[x][y][z]
1429
+ // foo.x.y.z
1430
+ // foo-x-y-z
1431
+ // foo x y z
1432
+ return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1433
+ return match[0] === '[]' ? '' : match[1] || match[0];
1434
+ });
1435
+ }
1436
+
1437
+ /**
1438
+ * Convert an array to an object.
1439
+ *
1440
+ * @param {Array<any>} arr - The array to convert to an object.
1441
+ *
1442
+ * @returns An object with the same keys and values as the array.
1443
+ */
1444
+ function arrayToObject(arr) {
1445
+ const obj = {};
1446
+ const keys = Object.keys(arr);
1447
+ let i;
1448
+ const len = keys.length;
1449
+ let key;
1450
+ for (i = 0; i < len; i++) {
1451
+ key = keys[i];
1452
+ obj[key] = arr[key];
1453
+ }
1454
+ return obj;
1455
+ }
1456
+
1457
+ /**
1458
+ * It takes a FormData object and returns a JavaScript object
1459
+ *
1460
+ * @param {string} formData The FormData object to convert to JSON.
1461
+ *
1462
+ * @returns {Object<string, any> | null} The converted object.
1463
+ */
1464
+ function formDataToJSON(formData) {
1465
+ function buildPath(path, value, target, index) {
1466
+ let name = path[index++];
1467
+ const isNumericKey = Number.isFinite(+name);
1468
+ const isLast = index >= path.length;
1469
+ name = !name && utils.isArray(target) ? target.length : name;
1470
+
1471
+ if (isLast) {
1472
+ if (utils.hasOwnProp(target, name)) {
1473
+ target[name] = [target[name], value];
1474
+ } else {
1475
+ target[name] = value;
1476
+ }
1477
+
1478
+ return !isNumericKey;
1479
+ }
1480
+
1481
+ if (!target[name] || !utils.isObject(target[name])) {
1482
+ target[name] = [];
1483
+ }
1484
+
1485
+ const result = buildPath(path, value, target[name], index);
1486
+
1487
+ if (result && utils.isArray(target[name])) {
1488
+ target[name] = arrayToObject(target[name]);
1489
+ }
1490
+
1491
+ return !isNumericKey;
1492
+ }
1493
+
1494
+ if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
1495
+ const obj = {};
1496
+
1497
+ utils.forEachEntry(formData, (name, value) => {
1498
+ buildPath(parsePropPath(name), value, obj, 0);
1499
+ });
1500
+
1501
+ return obj;
1502
+ }
1503
+
1504
+ return null;
1505
+ }
1014
1506
 
1015
1507
  /**
1016
1508
  * Resolve or reject a Promise based on response status.
@@ -1018,97 +1510,99 @@ var toFormData_1 = toFormData;
1018
1510
  * @param {Function} resolve A function that resolves the promise.
1019
1511
  * @param {Function} reject A function that rejects the promise.
1020
1512
  * @param {object} response The response.
1513
+ *
1514
+ * @returns {object} The response.
1021
1515
  */
1022
- var settle = function settle(resolve, reject, response) {
1023
- var validateStatus = response.config.validateStatus;
1516
+ function settle(resolve, reject, response) {
1517
+ const validateStatus = response.config.validateStatus;
1024
1518
  if (!response.status || !validateStatus || validateStatus(response.status)) {
1025
1519
  resolve(response);
1026
1520
  } else {
1027
- reject(new AxiosError_1(
1521
+ reject(new AxiosError(
1028
1522
  'Request failed with status code ' + response.status,
1029
- [AxiosError_1.ERR_BAD_REQUEST, AxiosError_1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1523
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1030
1524
  response.config,
1031
1525
  response.request,
1032
1526
  response
1033
1527
  ));
1034
1528
  }
1035
- };
1529
+ }
1036
1530
 
1037
- var cookies = (
1038
- utils.isStandardBrowserEnv() ?
1531
+ const cookies = platform.isStandardBrowserEnv ?
1039
1532
 
1040
- // Standard browser envs support document.cookie
1041
- (function standardBrowserEnv() {
1042
- return {
1043
- write: function write(name, value, expires, path, domain, secure) {
1044
- var cookie = [];
1045
- cookie.push(name + '=' + encodeURIComponent(value));
1533
+ // Standard browser envs support document.cookie
1534
+ (function standardBrowserEnv() {
1535
+ return {
1536
+ write: function write(name, value, expires, path, domain, secure) {
1537
+ const cookie = [];
1538
+ cookie.push(name + '=' + encodeURIComponent(value));
1046
1539
 
1047
- if (utils.isNumber(expires)) {
1048
- cookie.push('expires=' + new Date(expires).toGMTString());
1049
- }
1540
+ if (utils.isNumber(expires)) {
1541
+ cookie.push('expires=' + new Date(expires).toGMTString());
1542
+ }
1050
1543
 
1051
- if (utils.isString(path)) {
1052
- cookie.push('path=' + path);
1053
- }
1544
+ if (utils.isString(path)) {
1545
+ cookie.push('path=' + path);
1546
+ }
1054
1547
 
1055
- if (utils.isString(domain)) {
1056
- cookie.push('domain=' + domain);
1057
- }
1548
+ if (utils.isString(domain)) {
1549
+ cookie.push('domain=' + domain);
1550
+ }
1058
1551
 
1059
- if (secure === true) {
1060
- cookie.push('secure');
1061
- }
1552
+ if (secure === true) {
1553
+ cookie.push('secure');
1554
+ }
1062
1555
 
1063
- document.cookie = cookie.join('; ');
1064
- },
1556
+ document.cookie = cookie.join('; ');
1557
+ },
1065
1558
 
1066
- read: function read(name) {
1067
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1068
- return (match ? decodeURIComponent(match[3]) : null);
1069
- },
1559
+ read: function read(name) {
1560
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1561
+ return (match ? decodeURIComponent(match[3]) : null);
1562
+ },
1070
1563
 
1071
- remove: function remove(name) {
1072
- this.write(name, '', Date.now() - 86400000);
1073
- }
1074
- };
1075
- })() :
1564
+ remove: function remove(name) {
1565
+ this.write(name, '', Date.now() - 86400000);
1566
+ }
1567
+ };
1568
+ })() :
1076
1569
 
1077
- // Non standard browser env (web workers, react-native) lack needed support.
1078
- (function nonStandardBrowserEnv() {
1079
- return {
1080
- write: function write() {},
1081
- read: function read() { return null; },
1082
- remove: function remove() {}
1083
- };
1084
- })()
1085
- );
1570
+ // Non standard browser env (web workers, react-native) lack needed support.
1571
+ (function nonStandardBrowserEnv() {
1572
+ return {
1573
+ write: function write() {},
1574
+ read: function read() { return null; },
1575
+ remove: function remove() {}
1576
+ };
1577
+ })();
1086
1578
 
1087
1579
  /**
1088
1580
  * Determines whether the specified URL is absolute
1089
1581
  *
1090
1582
  * @param {string} url The URL to test
1583
+ *
1091
1584
  * @returns {boolean} True if the specified URL is absolute, otherwise false
1092
1585
  */
1093
- var isAbsoluteURL = function isAbsoluteURL(url) {
1586
+ function isAbsoluteURL(url) {
1094
1587
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1095
1588
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1096
1589
  // by any combination of letters, digits, plus, period, or hyphen.
1097
1590
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1098
- };
1591
+ }
1099
1592
 
1100
1593
  /**
1101
1594
  * Creates a new URL by combining the specified URLs
1102
1595
  *
1103
1596
  * @param {string} baseURL The base URL
1104
1597
  * @param {string} relativeURL The relative URL
1598
+ *
1105
1599
  * @returns {string} The combined URL
1106
1600
  */
1107
- var combineURLs = function combineURLs(baseURL, relativeURL) {
1601
+ function combineURLs(baseURL, relativeURL) {
1108
1602
  return relativeURL
1109
1603
  ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1110
1604
  : baseURL;
1111
- };
1605
+ }
1112
1606
 
1113
1607
  /**
1114
1608
  * Creates a new URL by combining the baseURL with the requestedURL,
@@ -1117,23 +1611,111 @@ var combineURLs = function combineURLs(baseURL, relativeURL) {
1117
1611
  *
1118
1612
  * @param {string} baseURL The base URL
1119
1613
  * @param {string} requestedURL Absolute or relative URL to combine
1614
+ *
1120
1615
  * @returns {string} The combined full path
1121
1616
  */
1122
- var buildFullPath = function buildFullPath(baseURL, requestedURL) {
1617
+ function buildFullPath(baseURL, requestedURL) {
1123
1618
  if (baseURL && !isAbsoluteURL(requestedURL)) {
1124
1619
  return combineURLs(baseURL, requestedURL);
1125
1620
  }
1126
1621
  return requestedURL;
1127
- };
1622
+ }
1623
+
1624
+ const isURLSameOrigin = platform.isStandardBrowserEnv ?
1625
+
1626
+ // Standard browser envs have full support of the APIs needed to test
1627
+ // whether the request URL is of the same origin as current location.
1628
+ (function standardBrowserEnv() {
1629
+ const msie = /(msie|trident)/i.test(navigator.userAgent);
1630
+ const urlParsingNode = document.createElement('a');
1631
+ let originURL;
1632
+
1633
+ /**
1634
+ * Parse a URL to discover it's components
1635
+ *
1636
+ * @param {String} url The URL to be parsed
1637
+ * @returns {Object}
1638
+ */
1639
+ function resolveURL(url) {
1640
+ let href = url;
1641
+
1642
+ if (msie) {
1643
+ // IE needs attribute set twice to normalize properties
1644
+ urlParsingNode.setAttribute('href', href);
1645
+ href = urlParsingNode.href;
1646
+ }
1647
+
1648
+ urlParsingNode.setAttribute('href', href);
1649
+
1650
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1651
+ return {
1652
+ href: urlParsingNode.href,
1653
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1654
+ host: urlParsingNode.host,
1655
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1656
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1657
+ hostname: urlParsingNode.hostname,
1658
+ port: urlParsingNode.port,
1659
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1660
+ urlParsingNode.pathname :
1661
+ '/' + urlParsingNode.pathname
1662
+ };
1663
+ }
1664
+
1665
+ originURL = resolveURL(window.location.href);
1666
+
1667
+ /**
1668
+ * Determine if a URL shares the same origin as the current location
1669
+ *
1670
+ * @param {String} requestURL The URL to test
1671
+ * @returns {boolean} True if URL shares the same origin, otherwise false
1672
+ */
1673
+ return function isURLSameOrigin(requestURL) {
1674
+ const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1675
+ return (parsed.protocol === originURL.protocol &&
1676
+ parsed.host === originURL.host);
1677
+ };
1678
+ })() :
1679
+
1680
+ // Non standard browser envs (web workers, react-native) lack needed support.
1681
+ (function nonStandardBrowserEnv() {
1682
+ return function isURLSameOrigin() {
1683
+ return true;
1684
+ };
1685
+ })();
1686
+
1687
+ /**
1688
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1689
+ *
1690
+ * @param {string=} message The message.
1691
+ * @param {Object=} config The config.
1692
+ * @param {Object=} request The request.
1693
+ *
1694
+ * @returns {CanceledError} The created error.
1695
+ */
1696
+ function CanceledError(message, config, request) {
1697
+ // eslint-disable-next-line no-eq-null,eqeqeq
1698
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1699
+ this.name = 'CanceledError';
1700
+ }
1701
+
1702
+ utils.inherits(CanceledError, AxiosError, {
1703
+ __CANCEL__: true
1704
+ });
1705
+
1706
+ function parseProtocol(url) {
1707
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1708
+ return match && match[1] || '';
1709
+ }
1128
1710
 
1129
- // Headers whose duplicates are ignored by node
1711
+ // RawAxiosHeaders whose duplicates are ignored by node
1130
1712
  // c.f. https://nodejs.org/api/http.html#http_message_headers
1131
- var ignoreDuplicateOf = [
1713
+ const ignoreDuplicateOf = utils.toObjectSet([
1132
1714
  'age', 'authorization', 'content-length', 'content-type', 'etag',
1133
1715
  'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1134
1716
  'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1135
1717
  'referer', 'retry-after', 'user-agent'
1136
- ];
1718
+ ]);
1137
1719
 
1138
1720
  /**
1139
1721
  * Parse headers into an object
@@ -1145,131 +1727,393 @@ var ignoreDuplicateOf = [
1145
1727
  * Transfer-Encoding: chunked
1146
1728
  * ```
1147
1729
  *
1148
- * @param {String} headers Headers needing to be parsed
1730
+ * @param {String} rawHeaders Headers needing to be parsed
1731
+ *
1149
1732
  * @returns {Object} Headers parsed into an object
1150
1733
  */
1151
- var parseHeaders = function parseHeaders(headers) {
1152
- var parsed = {};
1153
- var key;
1154
- var val;
1155
- var i;
1734
+ const parseHeaders = rawHeaders => {
1735
+ const parsed = {};
1736
+ let key;
1737
+ let val;
1738
+ let i;
1156
1739
 
1157
- if (!headers) { return parsed; }
1158
-
1159
- utils.forEach(headers.split('\n'), function parser(line) {
1740
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1160
1741
  i = line.indexOf(':');
1161
- key = utils.trim(line.substr(0, i)).toLowerCase();
1162
- val = utils.trim(line.substr(i + 1));
1742
+ key = line.substring(0, i).trim().toLowerCase();
1743
+ val = line.substring(i + 1).trim();
1744
+
1745
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1746
+ return;
1747
+ }
1748
+
1749
+ if (key === 'set-cookie') {
1750
+ if (parsed[key]) {
1751
+ parsed[key].push(val);
1752
+ } else {
1753
+ parsed[key] = [val];
1754
+ }
1755
+ } else {
1756
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1757
+ }
1758
+ });
1759
+
1760
+ return parsed;
1761
+ };
1762
+
1763
+ const $internals = Symbol('internals');
1764
+ const $defaults = Symbol('defaults');
1765
+
1766
+ function normalizeHeader(header) {
1767
+ return header && String(header).trim().toLowerCase();
1768
+ }
1769
+
1770
+ function normalizeValue(value) {
1771
+ if (value === false || value == null) {
1772
+ return value;
1773
+ }
1774
+
1775
+ return String(value);
1776
+ }
1777
+
1778
+ function parseTokens(str) {
1779
+ const tokens = Object.create(null);
1780
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1781
+ let match;
1782
+
1783
+ while ((match = tokensRE.exec(str))) {
1784
+ tokens[match[1]] = match[2];
1785
+ }
1786
+
1787
+ return tokens;
1788
+ }
1789
+
1790
+ function matchHeaderValue(context, value, header, filter) {
1791
+ if (utils.isFunction(filter)) {
1792
+ return filter.call(this, value, header);
1793
+ }
1794
+
1795
+ if (!utils.isString(value)) return;
1796
+
1797
+ if (utils.isString(filter)) {
1798
+ return value.indexOf(filter) !== -1;
1799
+ }
1800
+
1801
+ if (utils.isRegExp(filter)) {
1802
+ return filter.test(value);
1803
+ }
1804
+ }
1805
+
1806
+ function formatHeader(header) {
1807
+ return header.trim()
1808
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1809
+ return char.toUpperCase() + str;
1810
+ });
1811
+ }
1812
+
1813
+ function buildAccessors(obj, header) {
1814
+ const accessorName = utils.toCamelCase(' ' + header);
1815
+
1816
+ ['get', 'set', 'has'].forEach(methodName => {
1817
+ Object.defineProperty(obj, methodName + accessorName, {
1818
+ value: function(arg1, arg2, arg3) {
1819
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1820
+ },
1821
+ configurable: true
1822
+ });
1823
+ });
1824
+ }
1825
+
1826
+ function findKey(obj, key) {
1827
+ key = key.toLowerCase();
1828
+ const keys = Object.keys(obj);
1829
+ let i = keys.length;
1830
+ let _key;
1831
+ while (i-- > 0) {
1832
+ _key = keys[i];
1833
+ if (key === _key.toLowerCase()) {
1834
+ return _key;
1835
+ }
1836
+ }
1837
+ return null;
1838
+ }
1839
+
1840
+ function AxiosHeaders(headers, defaults) {
1841
+ headers && this.set(headers);
1842
+ this[$defaults] = defaults || null;
1843
+ }
1844
+
1845
+ Object.assign(AxiosHeaders.prototype, {
1846
+ set: function(header, valueOrRewrite, rewrite) {
1847
+ const self = this;
1848
+
1849
+ function setHeader(_value, _header, _rewrite) {
1850
+ const lHeader = normalizeHeader(_header);
1851
+
1852
+ if (!lHeader) {
1853
+ throw new Error('header name must be a non-empty string');
1854
+ }
1855
+
1856
+ const key = findKey(self, lHeader);
1857
+
1858
+ if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
1859
+ return;
1860
+ }
1861
+
1862
+ if (utils.isArray(_value)) {
1863
+ _value = _value.map(normalizeValue);
1864
+ } else {
1865
+ _value = normalizeValue(_value);
1866
+ }
1867
+
1868
+ self[key || _header] = _value;
1869
+ }
1870
+
1871
+ if (utils.isPlainObject(header)) {
1872
+ utils.forEach(header, (_value, _header) => {
1873
+ setHeader(_value, _header, valueOrRewrite);
1874
+ });
1875
+ } else {
1876
+ setHeader(valueOrRewrite, header, rewrite);
1877
+ }
1878
+
1879
+ return this;
1880
+ },
1881
+
1882
+ get: function(header, parser) {
1883
+ header = normalizeHeader(header);
1884
+
1885
+ if (!header) return undefined;
1886
+
1887
+ const key = findKey(this, header);
1888
+
1889
+ if (key) {
1890
+ const value = this[key];
1891
+
1892
+ if (!parser) {
1893
+ return value;
1894
+ }
1895
+
1896
+ if (parser === true) {
1897
+ return parseTokens(value);
1898
+ }
1899
+
1900
+ if (utils.isFunction(parser)) {
1901
+ return parser.call(this, value, key);
1902
+ }
1903
+
1904
+ if (utils.isRegExp(parser)) {
1905
+ return parser.exec(value);
1906
+ }
1907
+
1908
+ throw new TypeError('parser must be boolean|regexp|function');
1909
+ }
1910
+ },
1911
+
1912
+ has: function(header, matcher) {
1913
+ header = normalizeHeader(header);
1914
+
1915
+ if (header) {
1916
+ const key = findKey(this, header);
1917
+
1918
+ return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1919
+ }
1920
+
1921
+ return false;
1922
+ },
1923
+
1924
+ delete: function(header, matcher) {
1925
+ const self = this;
1926
+ let deleted = false;
1927
+
1928
+ function deleteHeader(_header) {
1929
+ _header = normalizeHeader(_header);
1930
+
1931
+ if (_header) {
1932
+ const key = findKey(self, _header);
1933
+
1934
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1935
+ delete self[key];
1936
+
1937
+ deleted = true;
1938
+ }
1939
+ }
1940
+ }
1941
+
1942
+ if (utils.isArray(header)) {
1943
+ header.forEach(deleteHeader);
1944
+ } else {
1945
+ deleteHeader(header);
1946
+ }
1947
+
1948
+ return deleted;
1949
+ },
1950
+
1951
+ clear: function() {
1952
+ return Object.keys(this).forEach(this.delete.bind(this));
1953
+ },
1954
+
1955
+ normalize: function(format) {
1956
+ const self = this;
1957
+ const headers = {};
1958
+
1959
+ utils.forEach(this, (value, header) => {
1960
+ const key = findKey(headers, header);
1961
+
1962
+ if (key) {
1963
+ self[key] = normalizeValue(value);
1964
+ delete self[header];
1965
+ return;
1966
+ }
1967
+
1968
+ const normalized = format ? formatHeader(header) : String(header).trim();
1969
+
1970
+ if (normalized !== header) {
1971
+ delete self[header];
1972
+ }
1973
+
1974
+ self[normalized] = normalizeValue(value);
1975
+
1976
+ headers[normalized] = true;
1977
+ });
1978
+
1979
+ return this;
1980
+ },
1981
+
1982
+ toJSON: function() {
1983
+ const obj = Object.create(null);
1984
+
1985
+ utils.forEach(Object.assign({}, this[$defaults] || null, this),
1986
+ (value, header) => {
1987
+ if (value == null || value === false) return;
1988
+ obj[header] = utils.isArray(value) ? value.join(', ') : value;
1989
+ });
1990
+
1991
+ return obj;
1992
+ }
1993
+ });
1994
+
1995
+ Object.assign(AxiosHeaders, {
1996
+ from: function(thing) {
1997
+ if (utils.isString(thing)) {
1998
+ return new this(parseHeaders(thing));
1999
+ }
2000
+ return thing instanceof this ? thing : new this(thing);
2001
+ },
2002
+
2003
+ accessor: function(header) {
2004
+ const internals = this[$internals] = (this[$internals] = {
2005
+ accessors: {}
2006
+ });
2007
+
2008
+ const accessors = internals.accessors;
2009
+ const prototype = this.prototype;
2010
+
2011
+ function defineAccessor(_header) {
2012
+ const lHeader = normalizeHeader(_header);
2013
+
2014
+ if (!accessors[lHeader]) {
2015
+ buildAccessors(prototype, _header);
2016
+ accessors[lHeader] = true;
2017
+ }
2018
+ }
2019
+
2020
+ utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2021
+
2022
+ return this;
2023
+ }
2024
+ });
2025
+
2026
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
2027
+
2028
+ utils.freezeMethods(AxiosHeaders.prototype);
2029
+ utils.freezeMethods(AxiosHeaders);
2030
+
2031
+ /**
2032
+ * Calculate data maxRate
2033
+ * @param {Number} [samplesCount= 10]
2034
+ * @param {Number} [min= 1000]
2035
+ * @returns {Function}
2036
+ */
2037
+ function speedometer(samplesCount, min) {
2038
+ samplesCount = samplesCount || 10;
2039
+ const bytes = new Array(samplesCount);
2040
+ const timestamps = new Array(samplesCount);
2041
+ let head = 0;
2042
+ let tail = 0;
2043
+ let firstSampleTS;
1163
2044
 
1164
- if (key) {
1165
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
1166
- return;
1167
- }
1168
- if (key === 'set-cookie') {
1169
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
1170
- } else {
1171
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1172
- }
1173
- }
1174
- });
2045
+ min = min !== undefined ? min : 1000;
1175
2046
 
1176
- return parsed;
1177
- };
2047
+ return function push(chunkLength) {
2048
+ const now = Date.now();
1178
2049
 
1179
- var isURLSameOrigin = (
1180
- utils.isStandardBrowserEnv() ?
2050
+ const startedAt = timestamps[tail];
1181
2051
 
1182
- // Standard browser envs have full support of the APIs needed to test
1183
- // whether the request URL is of the same origin as current location.
1184
- (function standardBrowserEnv() {
1185
- var msie = /(msie|trident)/i.test(navigator.userAgent);
1186
- var urlParsingNode = document.createElement('a');
1187
- var originURL;
2052
+ if (!firstSampleTS) {
2053
+ firstSampleTS = now;
2054
+ }
1188
2055
 
1189
- /**
1190
- * Parse a URL to discover it's components
1191
- *
1192
- * @param {String} url The URL to be parsed
1193
- * @returns {Object}
1194
- */
1195
- function resolveURL(url) {
1196
- var href = url;
2056
+ bytes[head] = chunkLength;
2057
+ timestamps[head] = now;
1197
2058
 
1198
- if (msie) {
1199
- // IE needs attribute set twice to normalize properties
1200
- urlParsingNode.setAttribute('href', href);
1201
- href = urlParsingNode.href;
1202
- }
2059
+ let i = tail;
2060
+ let bytesCount = 0;
1203
2061
 
1204
- urlParsingNode.setAttribute('href', href);
2062
+ while (i !== head) {
2063
+ bytesCount += bytes[i++];
2064
+ i = i % samplesCount;
2065
+ }
1205
2066
 
1206
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1207
- return {
1208
- href: urlParsingNode.href,
1209
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1210
- host: urlParsingNode.host,
1211
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1212
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1213
- hostname: urlParsingNode.hostname,
1214
- port: urlParsingNode.port,
1215
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1216
- urlParsingNode.pathname :
1217
- '/' + urlParsingNode.pathname
1218
- };
1219
- }
2067
+ head = (head + 1) % samplesCount;
1220
2068
 
1221
- originURL = resolveURL(window.location.href);
2069
+ if (head === tail) {
2070
+ tail = (tail + 1) % samplesCount;
2071
+ }
1222
2072
 
1223
- /**
1224
- * Determine if a URL shares the same origin as the current location
1225
- *
1226
- * @param {String} requestURL The URL to test
1227
- * @returns {boolean} True if URL shares the same origin, otherwise false
1228
- */
1229
- return function isURLSameOrigin(requestURL) {
1230
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1231
- return (parsed.protocol === originURL.protocol &&
1232
- parsed.host === originURL.host);
1233
- };
1234
- })() :
2073
+ if (now - firstSampleTS < min) {
2074
+ return;
2075
+ }
1235
2076
 
1236
- // Non standard browser envs (web workers, react-native) lack needed support.
1237
- (function nonStandardBrowserEnv() {
1238
- return function isURLSameOrigin() {
1239
- return true;
1240
- };
1241
- })()
1242
- );
2077
+ const passed = startedAt && now - startedAt;
1243
2078
 
1244
- /**
1245
- * A `CanceledError` is an object that is thrown when an operation is canceled.
1246
- *
1247
- * @class
1248
- * @param {string=} message The message.
1249
- */
1250
- function CanceledError(message) {
1251
- // eslint-disable-next-line no-eq-null,eqeqeq
1252
- AxiosError_1.call(this, message == null ? 'canceled' : message, AxiosError_1.ERR_CANCELED);
1253
- this.name = 'CanceledError';
2079
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2080
+ };
1254
2081
  }
1255
2082
 
1256
- utils.inherits(CanceledError, AxiosError_1, {
1257
- __CANCEL__: true
1258
- });
2083
+ function progressEventReducer(listener, isDownloadStream) {
2084
+ let bytesNotified = 0;
2085
+ const _speedometer = speedometer(50, 250);
2086
+
2087
+ return e => {
2088
+ const loaded = e.loaded;
2089
+ const total = e.lengthComputable ? e.total : undefined;
2090
+ const progressBytes = loaded - bytesNotified;
2091
+ const rate = _speedometer(progressBytes);
2092
+ const inRange = loaded <= total;
2093
+
2094
+ bytesNotified = loaded;
2095
+
2096
+ const data = {
2097
+ loaded,
2098
+ total,
2099
+ progress: total ? (loaded / total) : undefined,
2100
+ bytes: progressBytes,
2101
+ rate: rate ? rate : undefined,
2102
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined
2103
+ };
1259
2104
 
1260
- var CanceledError_1 = CanceledError;
2105
+ data[isDownloadStream ? 'download' : 'upload'] = true;
1261
2106
 
1262
- var parseProtocol = function parseProtocol(url) {
1263
- var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1264
- return match && match[1] || '';
1265
- };
2107
+ listener(data);
2108
+ };
2109
+ }
1266
2110
 
1267
- var xhr = function xhrAdapter(config) {
2111
+ function xhrAdapter(config) {
1268
2112
  return new Promise(function dispatchXhrRequest(resolve, reject) {
1269
- var requestData = config.data;
1270
- var requestHeaders = config.headers;
1271
- var responseType = config.responseType;
1272
- var onCanceled;
2113
+ let requestData = config.data;
2114
+ const requestHeaders = AxiosHeaders.from(config.headers).normalize();
2115
+ const responseType = config.responseType;
2116
+ let onCanceled;
1273
2117
  function done() {
1274
2118
  if (config.cancelToken) {
1275
2119
  config.cancelToken.unsubscribe(onCanceled);
@@ -1280,20 +2124,20 @@ var xhr = function xhrAdapter(config) {
1280
2124
  }
1281
2125
  }
1282
2126
 
1283
- if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
1284
- delete requestHeaders['Content-Type']; // Let the browser set it
2127
+ if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
2128
+ requestHeaders.setContentType(false); // Let the browser set it
1285
2129
  }
1286
2130
 
1287
- var request = new XMLHttpRequest();
2131
+ let request = new XMLHttpRequest();
1288
2132
 
1289
2133
  // HTTP basic authentication
1290
2134
  if (config.auth) {
1291
- var username = config.auth.username || '';
1292
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
1293
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
2135
+ const username = config.auth.username || '';
2136
+ const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2137
+ requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
1294
2138
  }
1295
2139
 
1296
- var fullPath = buildFullPath(config.baseURL, config.url);
2140
+ const fullPath = buildFullPath(config.baseURL, config.url);
1297
2141
 
1298
2142
  request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
1299
2143
 
@@ -1305,16 +2149,18 @@ var xhr = function xhrAdapter(config) {
1305
2149
  return;
1306
2150
  }
1307
2151
  // Prepare the response
1308
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
1309
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2152
+ const responseHeaders = AxiosHeaders.from(
2153
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2154
+ );
2155
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1310
2156
  request.responseText : request.response;
1311
- var response = {
2157
+ const response = {
1312
2158
  data: responseData,
1313
2159
  status: request.status,
1314
2160
  statusText: request.statusText,
1315
2161
  headers: responseHeaders,
1316
- config: config,
1317
- request: request
2162
+ config,
2163
+ request
1318
2164
  };
1319
2165
 
1320
2166
  settle(function _resolve(value) {
@@ -1358,7 +2204,7 @@ var xhr = function xhrAdapter(config) {
1358
2204
  return;
1359
2205
  }
1360
2206
 
1361
- reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
2207
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
1362
2208
 
1363
2209
  // Clean up request
1364
2210
  request = null;
@@ -1368,7 +2214,7 @@ var xhr = function xhrAdapter(config) {
1368
2214
  request.onerror = function handleError() {
1369
2215
  // Real errors are hidden from us by the browser
1370
2216
  // onerror should only fire if it's a network error
1371
- reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request, request));
2217
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
1372
2218
 
1373
2219
  // Clean up request
1374
2220
  request = null;
@@ -1376,14 +2222,14 @@ var xhr = function xhrAdapter(config) {
1376
2222
 
1377
2223
  // Handle timeout
1378
2224
  request.ontimeout = function handleTimeout() {
1379
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1380
- var transitional$1 = config.transitional || transitional;
2225
+ let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2226
+ const transitional = config.transitional || transitionalDefaults;
1381
2227
  if (config.timeoutErrorMessage) {
1382
2228
  timeoutErrorMessage = config.timeoutErrorMessage;
1383
2229
  }
1384
- reject(new AxiosError_1(
2230
+ reject(new AxiosError(
1385
2231
  timeoutErrorMessage,
1386
- transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
2232
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
1387
2233
  config,
1388
2234
  request));
1389
2235
 
@@ -1394,27 +2240,23 @@ var xhr = function xhrAdapter(config) {
1394
2240
  // Add xsrf header
1395
2241
  // This is only done if running in a standard browser environment.
1396
2242
  // Specifically not if we're in a web worker, or react-native.
1397
- if (utils.isStandardBrowserEnv()) {
2243
+ if (platform.isStandardBrowserEnv) {
1398
2244
  // Add xsrf header
1399
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
1400
- cookies.read(config.xsrfCookieName) :
1401
- undefined;
2245
+ const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
2246
+ && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
1402
2247
 
1403
2248
  if (xsrfValue) {
1404
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
2249
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
1405
2250
  }
1406
2251
  }
1407
2252
 
2253
+ // Remove Content-Type if data is undefined
2254
+ requestData === undefined && requestHeaders.setContentType(null);
2255
+
1408
2256
  // Add headers to the request
1409
2257
  if ('setRequestHeader' in request) {
1410
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1411
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1412
- // Remove Content-Type if data is undefined
1413
- delete requestHeaders[key];
1414
- } else {
1415
- // Otherwise add header to the request
1416
- request.setRequestHeader(key, val);
1417
- }
2258
+ utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2259
+ request.setRequestHeader(key, val);
1418
2260
  });
1419
2261
  }
1420
2262
 
@@ -1430,22 +2272,22 @@ var xhr = function xhrAdapter(config) {
1430
2272
 
1431
2273
  // Handle progress if needed
1432
2274
  if (typeof config.onDownloadProgress === 'function') {
1433
- request.addEventListener('progress', config.onDownloadProgress);
2275
+ request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
1434
2276
  }
1435
2277
 
1436
2278
  // Not all browsers support upload events
1437
2279
  if (typeof config.onUploadProgress === 'function' && request.upload) {
1438
- request.upload.addEventListener('progress', config.onUploadProgress);
2280
+ request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
1439
2281
  }
1440
2282
 
1441
2283
  if (config.cancelToken || config.signal) {
1442
2284
  // Handle cancellation
1443
2285
  // eslint-disable-next-line func-names
1444
- onCanceled = function(cancel) {
2286
+ onCanceled = cancel => {
1445
2287
  if (!request) {
1446
2288
  return;
1447
2289
  }
1448
- reject(!cancel || (cancel && cancel.type) ? new CanceledError_1() : cancel);
2290
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
1449
2291
  request.abort();
1450
2292
  request = null;
1451
2293
  };
@@ -1456,48 +2298,81 @@ var xhr = function xhrAdapter(config) {
1456
2298
  }
1457
2299
  }
1458
2300
 
1459
- if (!requestData) {
1460
- requestData = null;
1461
- }
1462
-
1463
- var protocol = parseProtocol(fullPath);
2301
+ const protocol = parseProtocol(fullPath);
1464
2302
 
1465
- if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
1466
- reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
2303
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2304
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
1467
2305
  return;
1468
2306
  }
1469
2307
 
1470
2308
 
1471
2309
  // Send the request
1472
- request.send(requestData);
2310
+ request.send(requestData || null);
1473
2311
  });
2312
+ }
2313
+
2314
+ const adapters = {
2315
+ http: xhrAdapter,
2316
+ xhr: xhrAdapter
1474
2317
  };
1475
2318
 
1476
- // eslint-disable-next-line strict
1477
- var _null = null;
2319
+ const adapters$1 = {
2320
+ getAdapter: (nameOrAdapter) => {
2321
+ if(utils.isString(nameOrAdapter)){
2322
+ const adapter = adapters[nameOrAdapter];
1478
2323
 
1479
- var DEFAULT_CONTENT_TYPE = {
1480
- 'Content-Type': 'application/x-www-form-urlencoded'
2324
+ if (!nameOrAdapter) {
2325
+ throw Error(
2326
+ utils.hasOwnProp(nameOrAdapter) ?
2327
+ `Adapter '${nameOrAdapter}' is not available in the build` :
2328
+ `Can not resolve adapter '${nameOrAdapter}'`
2329
+ );
2330
+ }
2331
+
2332
+ return adapter
2333
+ }
2334
+
2335
+ if (!utils.isFunction(nameOrAdapter)) {
2336
+ throw new TypeError('adapter is not a function');
2337
+ }
2338
+
2339
+ return nameOrAdapter;
2340
+ },
2341
+ adapters
1481
2342
  };
1482
2343
 
1483
- function setContentTypeIfUnset(headers, value) {
1484
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
1485
- headers['Content-Type'] = value;
1486
- }
1487
- }
2344
+ const DEFAULT_CONTENT_TYPE = {
2345
+ 'Content-Type': 'application/x-www-form-urlencoded'
2346
+ };
1488
2347
 
2348
+ /**
2349
+ * If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
2350
+ * adapter
2351
+ *
2352
+ * @returns {Function}
2353
+ */
1489
2354
  function getDefaultAdapter() {
1490
- var adapter;
2355
+ let adapter;
1491
2356
  if (typeof XMLHttpRequest !== 'undefined') {
1492
2357
  // For browsers use XHR adapter
1493
- adapter = xhr;
1494
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
2358
+ adapter = adapters$1.getAdapter('xhr');
2359
+ } else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
1495
2360
  // For node use HTTP adapter
1496
- adapter = xhr;
2361
+ adapter = adapters$1.getAdapter('http');
1497
2362
  }
1498
2363
  return adapter;
1499
2364
  }
1500
2365
 
2366
+ /**
2367
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2368
+ * of the input
2369
+ *
2370
+ * @param {any} rawValue - The value to be stringified.
2371
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
2372
+ * @param {Function} encoder - A function that takes a value and returns a string.
2373
+ *
2374
+ * @returns {string} A stringified version of the rawValue.
2375
+ */
1501
2376
  function stringifySafely(rawValue, parser, encoder) {
1502
2377
  if (utils.isString(rawValue)) {
1503
2378
  try {
@@ -1513,18 +2388,31 @@ function stringifySafely(rawValue, parser, encoder) {
1513
2388
  return (encoder || JSON.stringify)(rawValue);
1514
2389
  }
1515
2390
 
1516
- var defaults = {
2391
+ const defaults = {
1517
2392
 
1518
- transitional: transitional,
2393
+ transitional: transitionalDefaults,
1519
2394
 
1520
2395
  adapter: getDefaultAdapter(),
1521
2396
 
1522
2397
  transformRequest: [function transformRequest(data, headers) {
1523
- normalizeHeaderName(headers, 'Accept');
1524
- normalizeHeaderName(headers, 'Content-Type');
2398
+ const contentType = headers.getContentType() || '';
2399
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
2400
+ const isObjectPayload = utils.isObject(data);
2401
+
2402
+ if (isObjectPayload && utils.isHTMLForm(data)) {
2403
+ data = new FormData(data);
2404
+ }
1525
2405
 
1526
- if (utils.isFormData(data) ||
1527
- utils.isArrayBuffer(data) ||
2406
+ const isFormData = utils.isFormData(data);
2407
+
2408
+ if (isFormData) {
2409
+ if (!hasJSONContentType) {
2410
+ return data;
2411
+ }
2412
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2413
+ }
2414
+
2415
+ if (utils.isArrayBuffer(data) ||
1528
2416
  utils.isBuffer(data) ||
1529
2417
  utils.isStream(data) ||
1530
2418
  utils.isFile(data) ||
@@ -1536,20 +2424,30 @@ var defaults = {
1536
2424
  return data.buffer;
1537
2425
  }
1538
2426
  if (utils.isURLSearchParams(data)) {
1539
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
2427
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1540
2428
  return data.toString();
1541
2429
  }
1542
2430
 
1543
- var isObjectPayload = utils.isObject(data);
1544
- var contentType = headers && headers['Content-Type'];
2431
+ let isFileList;
1545
2432
 
1546
- var isFileList;
2433
+ if (isObjectPayload) {
2434
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2435
+ return toURLEncodedForm(data, this.formSerializer).toString();
2436
+ }
2437
+
2438
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2439
+ const _FormData = this.env && this.env.FormData;
2440
+
2441
+ return toFormData(
2442
+ isFileList ? {'files[]': data} : data,
2443
+ _FormData && new _FormData(),
2444
+ this.formSerializer
2445
+ );
2446
+ }
2447
+ }
1547
2448
 
1548
- if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
1549
- var _FormData = this.env && this.env.FormData;
1550
- return toFormData_1(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
1551
- } else if (isObjectPayload || contentType === 'application/json') {
1552
- setContentTypeIfUnset(headers, 'application/json');
2449
+ if (isObjectPayload || hasJSONContentType ) {
2450
+ headers.setContentType('application/json', false);
1553
2451
  return stringifySafely(data);
1554
2452
  }
1555
2453
 
@@ -1557,18 +2455,20 @@ var defaults = {
1557
2455
  }],
1558
2456
 
1559
2457
  transformResponse: [function transformResponse(data) {
1560
- var transitional = this.transitional || defaults.transitional;
1561
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
1562
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1563
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
2458
+ const transitional = this.transitional || defaults.transitional;
2459
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2460
+ const JSONRequested = this.responseType === 'json';
2461
+
2462
+ if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
2463
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
2464
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1564
2465
 
1565
- if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
1566
2466
  try {
1567
2467
  return JSON.parse(data);
1568
2468
  } catch (e) {
1569
2469
  if (strictJSONParsing) {
1570
2470
  if (e.name === 'SyntaxError') {
1571
- throw AxiosError_1.from(e, AxiosError_1.ERR_BAD_RESPONSE, this, null, this.response);
2471
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1572
2472
  }
1573
2473
  throw e;
1574
2474
  }
@@ -1591,7 +2491,8 @@ var defaults = {
1591
2491
  maxBodyLength: -1,
1592
2492
 
1593
2493
  env: {
1594
- FormData: _null
2494
+ FormData: platform.classes.FormData,
2495
+ Blob: platform.classes.Blob
1595
2496
  },
1596
2497
 
1597
2498
  validateStatus: function validateStatus(status) {
@@ -1613,32 +2514,39 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1613
2514
  defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1614
2515
  });
1615
2516
 
1616
- var defaults_1 = defaults;
1617
-
1618
2517
  /**
1619
2518
  * Transform the data for a request or a response
1620
2519
  *
1621
- * @param {Object|String} data The data to be transformed
1622
- * @param {Array} headers The headers for the request or response
1623
2520
  * @param {Array|Function} fns A single function or Array of functions
2521
+ * @param {?Object} response The response object
2522
+ *
1624
2523
  * @returns {*} The resulting transformed data
1625
2524
  */
1626
- var transformData = function transformData(data, headers, fns) {
1627
- var context = this || defaults_1;
1628
- /*eslint no-param-reassign:0*/
2525
+ function transformData(fns, response) {
2526
+ const config = this || defaults;
2527
+ const context = response || config;
2528
+ const headers = AxiosHeaders.from(context.headers);
2529
+ let data = context.data;
2530
+
1629
2531
  utils.forEach(fns, function transform(fn) {
1630
- data = fn.call(context, data, headers);
2532
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1631
2533
  });
1632
2534
 
2535
+ headers.normalize();
2536
+
1633
2537
  return data;
1634
- };
2538
+ }
1635
2539
 
1636
- var isCancel = function isCancel(value) {
2540
+ function isCancel(value) {
1637
2541
  return !!(value && value.__CANCEL__);
1638
- };
2542
+ }
1639
2543
 
1640
2544
  /**
1641
2545
  * Throws a `CanceledError` if cancellation has been requested.
2546
+ *
2547
+ * @param {Object} config The config that is to be used for the request
2548
+ *
2549
+ * @returns {void}
1642
2550
  */
1643
2551
  function throwIfCancellationRequested(config) {
1644
2552
  if (config.cancelToken) {
@@ -1646,7 +2554,7 @@ function throwIfCancellationRequested(config) {
1646
2554
  }
1647
2555
 
1648
2556
  if (config.signal && config.signal.aborted) {
1649
- throw new CanceledError_1();
2557
+ throw new CanceledError();
1650
2558
  }
1651
2559
  }
1652
2560
 
@@ -1654,37 +2562,21 @@ function throwIfCancellationRequested(config) {
1654
2562
  * Dispatch a request to the server using the configured adapter.
1655
2563
  *
1656
2564
  * @param {object} config The config that is to be used for the request
2565
+ *
1657
2566
  * @returns {Promise} The Promise to be fulfilled
1658
2567
  */
1659
- var dispatchRequest = function dispatchRequest(config) {
2568
+ function dispatchRequest(config) {
1660
2569
  throwIfCancellationRequested(config);
1661
2570
 
1662
- // Ensure headers exist
1663
- config.headers = config.headers || {};
2571
+ config.headers = AxiosHeaders.from(config.headers);
1664
2572
 
1665
2573
  // Transform request data
1666
2574
  config.data = transformData.call(
1667
2575
  config,
1668
- config.data,
1669
- config.headers,
1670
2576
  config.transformRequest
1671
2577
  );
1672
2578
 
1673
- // Flatten headers
1674
- config.headers = utils.merge(
1675
- config.headers.common || {},
1676
- config.headers[config.method] || {},
1677
- config.headers
1678
- );
1679
-
1680
- utils.forEach(
1681
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
1682
- function cleanHeaderConfig(method) {
1683
- delete config.headers[method];
1684
- }
1685
- );
1686
-
1687
- var adapter = config.adapter || defaults_1.adapter;
2579
+ const adapter = config.adapter || defaults.adapter;
1688
2580
 
1689
2581
  return adapter(config).then(function onAdapterResolution(response) {
1690
2582
  throwIfCancellationRequested(config);
@@ -1692,11 +2584,12 @@ var dispatchRequest = function dispatchRequest(config) {
1692
2584
  // Transform response data
1693
2585
  response.data = transformData.call(
1694
2586
  config,
1695
- response.data,
1696
- response.headers,
1697
- config.transformResponse
2587
+ config.transformResponse,
2588
+ response
1698
2589
  );
1699
2590
 
2591
+ response.headers = AxiosHeaders.from(response.headers);
2592
+
1700
2593
  return response;
1701
2594
  }, function onAdapterRejection(reason) {
1702
2595
  if (!isCancel(reason)) {
@@ -1706,16 +2599,16 @@ var dispatchRequest = function dispatchRequest(config) {
1706
2599
  if (reason && reason.response) {
1707
2600
  reason.response.data = transformData.call(
1708
2601
  config,
1709
- reason.response.data,
1710
- reason.response.headers,
1711
- config.transformResponse
2602
+ config.transformResponse,
2603
+ reason.response
1712
2604
  );
2605
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
1713
2606
  }
1714
2607
  }
1715
2608
 
1716
2609
  return Promise.reject(reason);
1717
2610
  });
1718
- };
2611
+ }
1719
2612
 
1720
2613
  /**
1721
2614
  * Config-specific merge-function which creates a new config-object
@@ -1723,12 +2616,13 @@ var dispatchRequest = function dispatchRequest(config) {
1723
2616
  *
1724
2617
  * @param {Object} config1
1725
2618
  * @param {Object} config2
2619
+ *
1726
2620
  * @returns {Object} New object resulting from merging config2 to config1
1727
2621
  */
1728
- var mergeConfig = function mergeConfig(config1, config2) {
2622
+ function mergeConfig(config1, config2) {
1729
2623
  // eslint-disable-next-line no-param-reassign
1730
2624
  config2 = config2 || {};
1731
- var config = {};
2625
+ const config = {};
1732
2626
 
1733
2627
  function getMergedValue(target, source) {
1734
2628
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
@@ -1775,7 +2669,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
1775
2669
  }
1776
2670
  }
1777
2671
 
1778
- var mergeMap = {
2672
+ const mergeMap = {
1779
2673
  'url': valueFromConfig2,
1780
2674
  'method': valueFromConfig2,
1781
2675
  'data': valueFromConfig2,
@@ -1806,37 +2700,34 @@ var mergeConfig = function mergeConfig(config1, config2) {
1806
2700
  };
1807
2701
 
1808
2702
  utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
1809
- var merge = mergeMap[prop] || mergeDeepProperties;
1810
- var configValue = merge(prop);
2703
+ const merge = mergeMap[prop] || mergeDeepProperties;
2704
+ const configValue = merge(prop);
1811
2705
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
1812
2706
  });
1813
2707
 
1814
2708
  return config;
1815
- };
1816
-
1817
- var data = {
1818
- "version": "0.27.2"
1819
- };
1820
-
1821
- var VERSION = data.version;
2709
+ }
1822
2710
 
2711
+ const VERSION = "1.0.0";
1823
2712
 
1824
- var validators$1 = {};
2713
+ const validators$1 = {};
1825
2714
 
1826
2715
  // eslint-disable-next-line func-names
1827
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
2716
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
1828
2717
  validators$1[type] = function validator(thing) {
1829
2718
  return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1830
2719
  };
1831
2720
  });
1832
2721
 
1833
- var deprecatedWarnings = {};
2722
+ const deprecatedWarnings = {};
1834
2723
 
1835
2724
  /**
1836
2725
  * Transitional option validator
2726
+ *
1837
2727
  * @param {function|boolean?} validator - set to false if the transitional option has been removed
1838
2728
  * @param {string?} version - deprecated version / removed since version
1839
2729
  * @param {string?} message - some message with additional info
2730
+ *
1840
2731
  * @returns {function}
1841
2732
  */
1842
2733
  validators$1.transitional = function transitional(validator, version, message) {
@@ -1845,11 +2736,11 @@ validators$1.transitional = function transitional(validator, version, message) {
1845
2736
  }
1846
2737
 
1847
2738
  // eslint-disable-next-line func-names
1848
- return function(value, opt, opts) {
2739
+ return (value, opt, opts) => {
1849
2740
  if (validator === false) {
1850
- throw new AxiosError_1(
2741
+ throw new AxiosError(
1851
2742
  formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
1852
- AxiosError_1.ERR_DEPRECATED
2743
+ AxiosError.ERR_DEPRECATED
1853
2744
  );
1854
2745
  }
1855
2746
 
@@ -1870,162 +2761,192 @@ validators$1.transitional = function transitional(validator, version, message) {
1870
2761
 
1871
2762
  /**
1872
2763
  * Assert object's properties type
2764
+ *
1873
2765
  * @param {object} options
1874
2766
  * @param {object} schema
1875
2767
  * @param {boolean?} allowUnknown
2768
+ *
2769
+ * @returns {object}
1876
2770
  */
1877
2771
 
1878
2772
  function assertOptions(options, schema, allowUnknown) {
1879
2773
  if (typeof options !== 'object') {
1880
- throw new AxiosError_1('options must be an object', AxiosError_1.ERR_BAD_OPTION_VALUE);
2774
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
1881
2775
  }
1882
- var keys = Object.keys(options);
1883
- var i = keys.length;
2776
+ const keys = Object.keys(options);
2777
+ let i = keys.length;
1884
2778
  while (i-- > 0) {
1885
- var opt = keys[i];
1886
- var validator = schema[opt];
2779
+ const opt = keys[i];
2780
+ const validator = schema[opt];
1887
2781
  if (validator) {
1888
- var value = options[opt];
1889
- var result = value === undefined || validator(value, opt, options);
2782
+ const value = options[opt];
2783
+ const result = value === undefined || validator(value, opt, options);
1890
2784
  if (result !== true) {
1891
- throw new AxiosError_1('option ' + opt + ' must be ' + result, AxiosError_1.ERR_BAD_OPTION_VALUE);
2785
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
1892
2786
  }
1893
2787
  continue;
1894
2788
  }
1895
2789
  if (allowUnknown !== true) {
1896
- throw new AxiosError_1('Unknown option ' + opt, AxiosError_1.ERR_BAD_OPTION);
2790
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
1897
2791
  }
1898
2792
  }
1899
2793
  }
1900
2794
 
1901
- var validator = {
1902
- assertOptions: assertOptions,
2795
+ const validator = {
2796
+ assertOptions,
1903
2797
  validators: validators$1
1904
2798
  };
1905
2799
 
1906
- var validators = validator.validators;
2800
+ const validators = validator.validators;
2801
+
1907
2802
  /**
1908
2803
  * Create a new instance of Axios
1909
2804
  *
1910
2805
  * @param {Object} instanceConfig The default config for the instance
1911
- */
1912
- function Axios(instanceConfig) {
1913
- this.defaults = instanceConfig;
1914
- this.interceptors = {
1915
- request: new InterceptorManager_1(),
1916
- response: new InterceptorManager_1()
1917
- };
1918
- }
1919
-
1920
- /**
1921
- * Dispatch a request
1922
2806
  *
1923
- * @param {Object} config The config specific for this request (merged with this.defaults)
2807
+ * @return {Axios} A new instance of Axios
1924
2808
  */
1925
- Axios.prototype.request = function request(configOrUrl, config) {
1926
- /*eslint no-param-reassign:0*/
1927
- // Allow for axios('example/url'[, config]) a la fetch API
1928
- if (typeof configOrUrl === 'string') {
1929
- config = config || {};
1930
- config.url = configOrUrl;
1931
- } else {
1932
- config = configOrUrl || {};
2809
+ class Axios {
2810
+ constructor(instanceConfig) {
2811
+ this.defaults = instanceConfig;
2812
+ this.interceptors = {
2813
+ request: new InterceptorManager(),
2814
+ response: new InterceptorManager()
2815
+ };
1933
2816
  }
1934
2817
 
1935
- config = mergeConfig(this.defaults, config);
1936
-
1937
- // Set config.method
1938
- if (config.method) {
1939
- config.method = config.method.toLowerCase();
1940
- } else if (this.defaults.method) {
1941
- config.method = this.defaults.method.toLowerCase();
1942
- } else {
1943
- config.method = 'get';
1944
- }
2818
+ /**
2819
+ * Dispatch a request
2820
+ *
2821
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2822
+ * @param {?Object} config
2823
+ *
2824
+ * @returns {Promise} The Promise to be fulfilled
2825
+ */
2826
+ request(configOrUrl, config) {
2827
+ /*eslint no-param-reassign:0*/
2828
+ // Allow for axios('example/url'[, config]) a la fetch API
2829
+ if (typeof configOrUrl === 'string') {
2830
+ config = config || {};
2831
+ config.url = configOrUrl;
2832
+ } else {
2833
+ config = configOrUrl || {};
2834
+ }
1945
2835
 
1946
- var transitional = config.transitional;
2836
+ config = mergeConfig(this.defaults, config);
1947
2837
 
1948
- if (transitional !== undefined) {
1949
- validator.assertOptions(transitional, {
1950
- silentJSONParsing: validators.transitional(validators.boolean),
1951
- forcedJSONParsing: validators.transitional(validators.boolean),
1952
- clarifyTimeoutError: validators.transitional(validators.boolean)
1953
- }, false);
1954
- }
2838
+ const transitional = config.transitional;
1955
2839
 
1956
- // filter out skipped interceptors
1957
- var requestInterceptorChain = [];
1958
- var synchronousRequestInterceptors = true;
1959
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
1960
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
1961
- return;
2840
+ if (transitional !== undefined) {
2841
+ validator.assertOptions(transitional, {
2842
+ silentJSONParsing: validators.transitional(validators.boolean),
2843
+ forcedJSONParsing: validators.transitional(validators.boolean),
2844
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2845
+ }, false);
1962
2846
  }
1963
2847
 
1964
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2848
+ // Set config.method
2849
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
1965
2850
 
1966
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
1967
- });
2851
+ // Flatten headers
2852
+ const defaultHeaders = config.headers && utils.merge(
2853
+ config.headers.common,
2854
+ config.headers[config.method]
2855
+ );
1968
2856
 
1969
- var responseInterceptorChain = [];
1970
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
1971
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
1972
- });
2857
+ defaultHeaders && utils.forEach(
2858
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2859
+ function cleanHeaderConfig(method) {
2860
+ delete config.headers[method];
2861
+ }
2862
+ );
2863
+
2864
+ config.headers = new AxiosHeaders(config.headers, defaultHeaders);
2865
+
2866
+ // filter out skipped interceptors
2867
+ const requestInterceptorChain = [];
2868
+ let synchronousRequestInterceptors = true;
2869
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2870
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2871
+ return;
2872
+ }
2873
+
2874
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
1973
2875
 
1974
- var promise;
2876
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2877
+ });
2878
+
2879
+ const responseInterceptorChain = [];
2880
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2881
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2882
+ });
2883
+
2884
+ let promise;
2885
+ let i = 0;
2886
+ let len;
1975
2887
 
1976
- if (!synchronousRequestInterceptors) {
1977
- var chain = [dispatchRequest, undefined];
2888
+ if (!synchronousRequestInterceptors) {
2889
+ const chain = [dispatchRequest.bind(this), undefined];
2890
+ chain.unshift.apply(chain, requestInterceptorChain);
2891
+ chain.push.apply(chain, responseInterceptorChain);
2892
+ len = chain.length;
1978
2893
 
1979
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
1980
- chain = chain.concat(responseInterceptorChain);
2894
+ promise = Promise.resolve(config);
1981
2895
 
1982
- promise = Promise.resolve(config);
1983
- while (chain.length) {
1984
- promise = promise.then(chain.shift(), chain.shift());
2896
+ while (i < len) {
2897
+ promise = promise.then(chain[i++], chain[i++]);
2898
+ }
2899
+
2900
+ return promise;
1985
2901
  }
1986
2902
 
1987
- return promise;
1988
- }
2903
+ len = requestInterceptorChain.length;
1989
2904
 
2905
+ let newConfig = config;
2906
+
2907
+ i = 0;
2908
+
2909
+ while (i < len) {
2910
+ const onFulfilled = requestInterceptorChain[i++];
2911
+ const onRejected = requestInterceptorChain[i++];
2912
+ try {
2913
+ newConfig = onFulfilled(newConfig);
2914
+ } catch (error) {
2915
+ onRejected.call(this, error);
2916
+ break;
2917
+ }
2918
+ }
1990
2919
 
1991
- var newConfig = config;
1992
- while (requestInterceptorChain.length) {
1993
- var onFulfilled = requestInterceptorChain.shift();
1994
- var onRejected = requestInterceptorChain.shift();
1995
2920
  try {
1996
- newConfig = onFulfilled(newConfig);
2921
+ promise = dispatchRequest.call(this, newConfig);
1997
2922
  } catch (error) {
1998
- onRejected(error);
1999
- break;
2923
+ return Promise.reject(error);
2000
2924
  }
2001
- }
2002
2925
 
2003
- try {
2004
- promise = dispatchRequest(newConfig);
2005
- } catch (error) {
2006
- return Promise.reject(error);
2007
- }
2926
+ i = 0;
2927
+ len = responseInterceptorChain.length;
2008
2928
 
2009
- while (responseInterceptorChain.length) {
2010
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
2011
- }
2929
+ while (i < len) {
2930
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2931
+ }
2012
2932
 
2013
- return promise;
2014
- };
2933
+ return promise;
2934
+ }
2015
2935
 
2016
- Axios.prototype.getUri = function getUri(config) {
2017
- config = mergeConfig(this.defaults, config);
2018
- var fullPath = buildFullPath(config.baseURL, config.url);
2019
- return buildURL(fullPath, config.params, config.paramsSerializer);
2020
- };
2936
+ getUri(config) {
2937
+ config = mergeConfig(this.defaults, config);
2938
+ const fullPath = buildFullPath(config.baseURL, config.url);
2939
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2940
+ }
2941
+ }
2021
2942
 
2022
2943
  // Provide aliases for supported request methods
2023
2944
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2024
2945
  /*eslint func-names:0*/
2025
2946
  Axios.prototype[method] = function(url, config) {
2026
2947
  return this.request(mergeConfig(config || {}, {
2027
- method: method,
2028
- url: url,
2948
+ method,
2949
+ url,
2029
2950
  data: (config || {}).data
2030
2951
  }));
2031
2952
  };
@@ -2037,12 +2958,12 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2037
2958
  function generateHTTPMethod(isForm) {
2038
2959
  return function httpMethod(url, data, config) {
2039
2960
  return this.request(mergeConfig(config || {}, {
2040
- method: method,
2961
+ method,
2041
2962
  headers: isForm ? {
2042
2963
  'Content-Type': 'multipart/form-data'
2043
2964
  } : {},
2044
- url: url,
2045
- data: data
2965
+ url,
2966
+ data
2046
2967
  }));
2047
2968
  };
2048
2969
  }
@@ -2052,123 +2973,121 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2052
2973
  Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2053
2974
  });
2054
2975
 
2055
- var Axios_1 = Axios;
2056
-
2057
2976
  /**
2058
2977
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
2059
2978
  *
2060
- * @class
2061
2979
  * @param {Function} executor The executor function.
2980
+ *
2981
+ * @returns {CancelToken}
2062
2982
  */
2063
- function CancelToken(executor) {
2064
- if (typeof executor !== 'function') {
2065
- throw new TypeError('executor must be a function.');
2066
- }
2983
+ class CancelToken {
2984
+ constructor(executor) {
2985
+ if (typeof executor !== 'function') {
2986
+ throw new TypeError('executor must be a function.');
2987
+ }
2067
2988
 
2068
- var resolvePromise;
2989
+ let resolvePromise;
2069
2990
 
2070
- this.promise = new Promise(function promiseExecutor(resolve) {
2071
- resolvePromise = resolve;
2072
- });
2991
+ this.promise = new Promise(function promiseExecutor(resolve) {
2992
+ resolvePromise = resolve;
2993
+ });
2073
2994
 
2074
- var token = this;
2995
+ const token = this;
2075
2996
 
2076
- // eslint-disable-next-line func-names
2077
- this.promise.then(function(cancel) {
2078
- if (!token._listeners) return;
2997
+ // eslint-disable-next-line func-names
2998
+ this.promise.then(cancel => {
2999
+ if (!token._listeners) return;
2079
3000
 
2080
- var i;
2081
- var l = token._listeners.length;
3001
+ let i = token._listeners.length;
2082
3002
 
2083
- for (i = 0; i < l; i++) {
2084
- token._listeners[i](cancel);
2085
- }
2086
- token._listeners = null;
2087
- });
3003
+ while (i-- > 0) {
3004
+ token._listeners[i](cancel);
3005
+ }
3006
+ token._listeners = null;
3007
+ });
2088
3008
 
2089
- // eslint-disable-next-line func-names
2090
- this.promise.then = function(onfulfilled) {
2091
- var _resolve;
2092
3009
  // eslint-disable-next-line func-names
2093
- var promise = new Promise(function(resolve) {
2094
- token.subscribe(resolve);
2095
- _resolve = resolve;
2096
- }).then(onfulfilled);
3010
+ this.promise.then = onfulfilled => {
3011
+ let _resolve;
3012
+ // eslint-disable-next-line func-names
3013
+ const promise = new Promise(resolve => {
3014
+ token.subscribe(resolve);
3015
+ _resolve = resolve;
3016
+ }).then(onfulfilled);
2097
3017
 
2098
- promise.cancel = function reject() {
2099
- token.unsubscribe(_resolve);
2100
- };
3018
+ promise.cancel = function reject() {
3019
+ token.unsubscribe(_resolve);
3020
+ };
2101
3021
 
2102
- return promise;
2103
- };
3022
+ return promise;
3023
+ };
2104
3024
 
2105
- executor(function cancel(message) {
2106
- if (token.reason) {
2107
- // Cancellation has already been requested
2108
- return;
2109
- }
3025
+ executor(function cancel(message, config, request) {
3026
+ if (token.reason) {
3027
+ // Cancellation has already been requested
3028
+ return;
3029
+ }
2110
3030
 
2111
- token.reason = new CanceledError_1(message);
2112
- resolvePromise(token.reason);
2113
- });
2114
- }
3031
+ token.reason = new CanceledError(message, config, request);
3032
+ resolvePromise(token.reason);
3033
+ });
3034
+ }
2115
3035
 
2116
- /**
2117
- * Throws a `CanceledError` if cancellation has been requested.
2118
- */
2119
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
2120
- if (this.reason) {
2121
- throw this.reason;
3036
+ /**
3037
+ * Throws a `CanceledError` if cancellation has been requested.
3038
+ */
3039
+ throwIfRequested() {
3040
+ if (this.reason) {
3041
+ throw this.reason;
3042
+ }
2122
3043
  }
2123
- };
2124
3044
 
2125
- /**
2126
- * Subscribe to the cancel signal
2127
- */
3045
+ /**
3046
+ * Subscribe to the cancel signal
3047
+ */
2128
3048
 
2129
- CancelToken.prototype.subscribe = function subscribe(listener) {
2130
- if (this.reason) {
2131
- listener(this.reason);
2132
- return;
2133
- }
3049
+ subscribe(listener) {
3050
+ if (this.reason) {
3051
+ listener(this.reason);
3052
+ return;
3053
+ }
2134
3054
 
2135
- if (this._listeners) {
2136
- this._listeners.push(listener);
2137
- } else {
2138
- this._listeners = [listener];
3055
+ if (this._listeners) {
3056
+ this._listeners.push(listener);
3057
+ } else {
3058
+ this._listeners = [listener];
3059
+ }
2139
3060
  }
2140
- };
2141
3061
 
2142
- /**
2143
- * Unsubscribe from the cancel signal
2144
- */
3062
+ /**
3063
+ * Unsubscribe from the cancel signal
3064
+ */
2145
3065
 
2146
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
2147
- if (!this._listeners) {
2148
- return;
2149
- }
2150
- var index = this._listeners.indexOf(listener);
2151
- if (index !== -1) {
2152
- this._listeners.splice(index, 1);
3066
+ unsubscribe(listener) {
3067
+ if (!this._listeners) {
3068
+ return;
3069
+ }
3070
+ const index = this._listeners.indexOf(listener);
3071
+ if (index !== -1) {
3072
+ this._listeners.splice(index, 1);
3073
+ }
2153
3074
  }
2154
- };
2155
-
2156
- /**
2157
- * Returns an object that contains a new `CancelToken` and a function that, when called,
2158
- * cancels the `CancelToken`.
2159
- */
2160
- CancelToken.source = function source() {
2161
- var cancel;
2162
- var token = new CancelToken(function executor(c) {
2163
- cancel = c;
2164
- });
2165
- return {
2166
- token: token,
2167
- cancel: cancel
2168
- };
2169
- };
2170
3075
 
2171
- var CancelToken_1 = CancelToken;
3076
+ /**
3077
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3078
+ * cancels the `CancelToken`.
3079
+ */
3080
+ static source() {
3081
+ let cancel;
3082
+ const token = new CancelToken(function executor(c) {
3083
+ cancel = c;
3084
+ });
3085
+ return {
3086
+ token,
3087
+ cancel
3088
+ };
3089
+ }
3090
+ }
2172
3091
 
2173
3092
  /**
2174
3093
  * Syntactic sugar for invoking a function and expanding an array for arguments.
@@ -2188,39 +3107,42 @@ var CancelToken_1 = CancelToken;
2188
3107
  * ```
2189
3108
  *
2190
3109
  * @param {Function} callback
3110
+ *
2191
3111
  * @returns {Function}
2192
3112
  */
2193
- var spread = function spread(callback) {
3113
+ function spread(callback) {
2194
3114
  return function wrap(arr) {
2195
3115
  return callback.apply(null, arr);
2196
3116
  };
2197
- };
3117
+ }
2198
3118
 
2199
3119
  /**
2200
3120
  * Determines whether the payload is an error thrown by Axios
2201
3121
  *
2202
3122
  * @param {*} payload The value to test
3123
+ *
2203
3124
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2204
3125
  */
2205
- var isAxiosError = function isAxiosError(payload) {
3126
+ function isAxiosError(payload) {
2206
3127
  return utils.isObject(payload) && (payload.isAxiosError === true);
2207
- };
3128
+ }
2208
3129
 
2209
3130
  /**
2210
3131
  * Create an instance of Axios
2211
3132
  *
2212
3133
  * @param {Object} defaultConfig The default config for the instance
2213
- * @return {Axios} A new instance of Axios
3134
+ *
3135
+ * @returns {Axios} A new instance of Axios
2214
3136
  */
2215
3137
  function createInstance(defaultConfig) {
2216
- var context = new Axios_1(defaultConfig);
2217
- var instance = bind(Axios_1.prototype.request, context);
3138
+ const context = new Axios(defaultConfig);
3139
+ const instance = bind(Axios.prototype.request, context);
2218
3140
 
2219
3141
  // Copy axios.prototype to instance
2220
- utils.extend(instance, Axios_1.prototype, context);
3142
+ utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
2221
3143
 
2222
3144
  // Copy context to instance
2223
- utils.extend(instance, context);
3145
+ utils.extend(instance, context, null, {allOwnKeys: true});
2224
3146
 
2225
3147
  // Factory for creating new instances
2226
3148
  instance.create = function create(instanceConfig) {
@@ -2231,40 +3153,37 @@ function createInstance(defaultConfig) {
2231
3153
  }
2232
3154
 
2233
3155
  // Create the default instance to be exported
2234
- var axios$1 = createInstance(defaults_1);
3156
+ const axios = createInstance(defaults);
2235
3157
 
2236
3158
  // Expose Axios class to allow class inheritance
2237
- axios$1.Axios = Axios_1;
3159
+ axios.Axios = Axios;
2238
3160
 
2239
3161
  // Expose Cancel & CancelToken
2240
- axios$1.CanceledError = CanceledError_1;
2241
- axios$1.CancelToken = CancelToken_1;
2242
- axios$1.isCancel = isCancel;
2243
- axios$1.VERSION = data.version;
2244
- axios$1.toFormData = toFormData_1;
3162
+ axios.CanceledError = CanceledError;
3163
+ axios.CancelToken = CancelToken;
3164
+ axios.isCancel = isCancel;
3165
+ axios.VERSION = VERSION;
3166
+ axios.toFormData = toFormData;
2245
3167
 
2246
3168
  // Expose AxiosError class
2247
- axios$1.AxiosError = AxiosError_1;
3169
+ axios.AxiosError = AxiosError;
2248
3170
 
2249
3171
  // alias for CanceledError for backward compatibility
2250
- axios$1.Cancel = axios$1.CanceledError;
3172
+ axios.Cancel = axios.CanceledError;
2251
3173
 
2252
3174
  // Expose all/spread
2253
- axios$1.all = function all(promises) {
3175
+ axios.all = function all(promises) {
2254
3176
  return Promise.all(promises);
2255
3177
  };
2256
- axios$1.spread = spread;
2257
3178
 
2258
- // Expose isAxiosError
2259
- axios$1.isAxiosError = isAxiosError;
2260
-
2261
- var axios_1 = axios$1;
3179
+ axios.spread = spread;
2262
3180
 
2263
- // Allow use of default import syntax in TypeScript
2264
- var _default = axios$1;
2265
- axios_1.default = _default;
3181
+ // Expose isAxiosError
3182
+ axios.isAxiosError = isAxiosError;
2266
3183
 
2267
- var axios = axios_1;
3184
+ axios.formToJSON = thing => {
3185
+ return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3186
+ };
2268
3187
 
2269
3188
  // --------------------------------------------------------[ mutable store ]
2270
3189
  const storeDef = {