mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Optimize _.isEmpty. [closes #1888]
This commit is contained in:
13
lodash.js
13
lodash.js
@@ -9550,9 +9550,16 @@
|
||||
* // => false
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
return (!isObjectLike(value) || isFunction(value.splice))
|
||||
? !size(value)
|
||||
: !keys(value).length;
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || isString(value) || isArguments(value) || isFunction(value.splice))) {
|
||||
return !value.length;
|
||||
}
|
||||
for (var key in value) {
|
||||
if (hasOwnProperty.call(value, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user