axios 1.0.0-alpha.1 → 1.1.0

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

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