优化首页的下拉刷新、数据排序、绑定后刷新
This commit is contained in:
42
node_modules/axios/lib/utils.js
generated
vendored
42
node_modules/axios/lib/utils.js
generated
vendored
@ -136,6 +136,27 @@ const isPlainObject = (val) => {
|
||||
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an empty object (safely handles Buffers)
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is an empty object, otherwise false
|
||||
*/
|
||||
const isEmptyObject = (val) => {
|
||||
// Early return for non-objects or Buffers to prevent RangeError
|
||||
if (!isObject(val) || isBuffer(val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
||||
} catch (e) {
|
||||
// Fallback for any other objects that might cause RangeError with Object.keys()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Date
|
||||
*
|
||||
@ -258,6 +279,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
||||
fn.call(null, obj[i], i, obj);
|
||||
}
|
||||
} else {
|
||||
// Buffer check
|
||||
if (isBuffer(obj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate over object keys
|
||||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
||||
const len = keys.length;
|
||||
@ -271,6 +297,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
||||
}
|
||||
|
||||
function findKey(obj, key) {
|
||||
if (isBuffer(obj)){
|
||||
return null;
|
||||
}
|
||||
|
||||
key = key.toLowerCase();
|
||||
const keys = Object.keys(obj);
|
||||
let i = keys.length;
|
||||
@ -311,7 +341,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
||||
* @returns {Object} Result of all merge properties
|
||||
*/
|
||||
function merge(/* obj1, obj2, obj3, ... */) {
|
||||
const {caseless} = isContextDefined(this) && this || {};
|
||||
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
||||
const result = {};
|
||||
const assignValue = (val, key) => {
|
||||
const targetKey = caseless && findKey(result, key) || key;
|
||||
@ -321,7 +351,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
||||
result[targetKey] = merge({}, val);
|
||||
} else if (isArray(val)) {
|
||||
result[targetKey] = val.slice();
|
||||
} else {
|
||||
} else if (!skipUndefined || !isUndefined(val)) {
|
||||
result[targetKey] = val;
|
||||
}
|
||||
}
|
||||
@ -603,6 +633,8 @@ const toFiniteNumber = (value, defaultValue) => {
|
||||
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
@ -624,6 +656,11 @@ const toJSONObject = (obj) => {
|
||||
return;
|
||||
}
|
||||
|
||||
//Buffer check
|
||||
if (isBuffer(source)) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if(!('toJSON' in source)) {
|
||||
stack[i] = source;
|
||||
const target = isArray(source) ? [] : {};
|
||||
@ -695,6 +732,7 @@ export default {
|
||||
isBoolean,
|
||||
isObject,
|
||||
isPlainObject,
|
||||
isEmptyObject,
|
||||
isReadableStream,
|
||||
isRequest,
|
||||
isResponse,
|
||||
|
||||
Reference in New Issue
Block a user