mirror of
https://github.com/axios/axios.git
synced 2026-04-11 02:11:50 +08:00
fix: fixed performance issue in isEmptyObject() (#6484)
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
parent
68f97f7588
commit
62610f69ad
10
lib/utils.js
10
lib/utils.js
@ -131,7 +131,15 @@ function isPlainObject(val) {
|
||||
* @return {boolean} True if value is a empty Object, otherwise false
|
||||
*/
|
||||
function isEmptyObject(val) {
|
||||
return val && Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
||||
if (!isPlainObject(val)) {
|
||||
return false;
|
||||
}
|
||||
for (var key in val) {
|
||||
if (Object.prototype.hasOwnProperty.call(val, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user