mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add support for maps and sets to _.isEmpty. [closes #2159]
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -10361,11 +10361,15 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is an empty object or collection. A value is considered
|
||||
* empty if it's an `arguments` object, array, buffer, string, or jQuery-like
|
||||
* collection with a length of `0` or has no own enumerable string keyed
|
||||
* Checks if `value` is an empty object, collection, map, or set.
|
||||
*
|
||||
* Objects are considered empty if they have no own enumerable string keyed
|
||||
* properties.
|
||||
*
|
||||
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
||||
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
||||
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
@@ -10400,6 +10404,12 @@
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isObjectLike(value)) {
|
||||
var tag = getTag(value);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return !value.size;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user