mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Update Webpack + deps, remove now unnecessary polyfills (#2410)
* Update deps * handles webpack 1 -> 4 migration * remove promise helpers from dev files assume `Promise` is available, or polyfilled by the consumer * Remove isArray util. `isArray` has good coverage, even in IE9. So lets remove the custom polyfill. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray also resolves a few lint issues * Remove trim util String.protoype.trim has good coverage (including IE9) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim Also, the http adapter already uses the native method.
This commit is contained in:
committed by
Felipe Martins
parent
29da6b24db
commit
189b34c45a
+8
-32
@@ -3,21 +3,9 @@
|
||||
var bind = require('./helpers/bind');
|
||||
var isBuffer = require('is-buffer');
|
||||
|
||||
/*global toString:true*/
|
||||
|
||||
// utils is a library of generic helper functions non-specific to axios
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Determine if a value is an Array
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Array, otherwise false
|
||||
*/
|
||||
function isArray(val) {
|
||||
return toString.call(val) === '[object Array]';
|
||||
}
|
||||
var _toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Determine if a value is an ArrayBuffer
|
||||
@@ -26,7 +14,7 @@ function isArray(val) {
|
||||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBuffer(val) {
|
||||
return toString.call(val) === '[object ArrayBuffer]';
|
||||
return _toString.call(val) === '[object ArrayBuffer]';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +90,7 @@ function isObject(val) {
|
||||
* @returns {boolean} True if value is a Date, otherwise false
|
||||
*/
|
||||
function isDate(val) {
|
||||
return toString.call(val) === '[object Date]';
|
||||
return _toString.call(val) === '[object Date]';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +100,7 @@ function isDate(val) {
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
function isFile(val) {
|
||||
return toString.call(val) === '[object File]';
|
||||
return _toString.call(val) === '[object File]';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +110,7 @@ function isFile(val) {
|
||||
* @returns {boolean} True if value is a Blob, otherwise false
|
||||
*/
|
||||
function isBlob(val) {
|
||||
return toString.call(val) === '[object Blob]';
|
||||
return _toString.call(val) === '[object Blob]';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +120,7 @@ function isBlob(val) {
|
||||
* @returns {boolean} True if value is a Function, otherwise false
|
||||
*/
|
||||
function isFunction(val) {
|
||||
return toString.call(val) === '[object Function]';
|
||||
return _toString.call(val) === '[object Function]';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,16 +143,6 @@ function isURLSearchParams(val) {
|
||||
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim excess whitespace off the beginning and end of a string
|
||||
*
|
||||
* @param {String} str The String to trim
|
||||
* @returns {String} The String freed of excess whitespace
|
||||
*/
|
||||
function trim(str) {
|
||||
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
*
|
||||
@@ -216,7 +194,7 @@ function forEach(obj, fn) {
|
||||
obj = [obj];
|
||||
}
|
||||
|
||||
if (isArray(obj)) {
|
||||
if (Array.isArray(obj)) {
|
||||
// Iterate over array values
|
||||
for (var i = 0, l = obj.length; i < l; i++) {
|
||||
fn.call(null, obj[i], i, obj);
|
||||
@@ -310,7 +288,6 @@ function extend(a, b, thisArg) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isArray: isArray,
|
||||
isArrayBuffer: isArrayBuffer,
|
||||
isBuffer: isBuffer,
|
||||
isFormData: isFormData,
|
||||
@@ -329,6 +306,5 @@ module.exports = {
|
||||
forEach: forEach,
|
||||
merge: merge,
|
||||
deepMerge: deepMerge,
|
||||
extend: extend,
|
||||
trim: trim
|
||||
extend: extend
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user