mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Bump to v4.15.0.
This commit is contained in:
24
isEmpty.js
24
isEmpty.js
@@ -3,10 +3,7 @@ import isArguments from './isArguments.js';
|
||||
import isArray from './isArray.js';
|
||||
import isArrayLike from './isArrayLike.js';
|
||||
import isBuffer from './isBuffer.js';
|
||||
import isFunction from './isFunction.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
import isPrototype from './_isPrototype.js';
|
||||
import isString from './isString.js';
|
||||
import nativeKeys from './_nativeKeys.js';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
@@ -60,24 +57,23 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || isString(value) || isFunction(value.splice) ||
|
||||
isArguments(value) || isBuffer(value))) {
|
||||
(isArray(value) || typeof value == 'string' ||
|
||||
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
if (isObjectLike(value)) {
|
||||
var tag = getTag(value);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return !value.size;
|
||||
}
|
||||
var tag = getTag(value);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return !value.size;
|
||||
}
|
||||
if (nonEnumShadows || isPrototype(value)) {
|
||||
return !nativeKeys(value).length;
|
||||
}
|
||||
var isProto = isPrototype(value);
|
||||
for (var key in value) {
|
||||
if (hasOwnProperty.call(value, key) &&
|
||||
!(isProto && key == 'constructor')) {
|
||||
if (hasOwnProperty.call(value, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !(nonEnumShadows && nativeKeys(value).length);
|
||||
return true;
|
||||
}
|
||||
|
||||
export default isEmpty;
|
||||
|
||||
Reference in New Issue
Block a user