mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
added an isEmpty function that works on arrays and objects
This commit is contained in:
@@ -146,9 +146,7 @@
|
||||
if (_.isArray(obj)) return _.indexOf(obj, target) != -1;
|
||||
var found = false;
|
||||
_.each(obj, function(value) {
|
||||
if (found = value === target) {
|
||||
throw '__break__';
|
||||
}
|
||||
if (found = value === target) throw '__break__';
|
||||
});
|
||||
return found;
|
||||
};
|
||||
@@ -409,6 +407,11 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
// Is a given array or object empty?
|
||||
_.isEmpty = function(obj) {
|
||||
return (_.isArray(obj) ? obj : _.values(obj)).length == 0;
|
||||
};
|
||||
|
||||
// Is a given value a DOM element?
|
||||
_.isElement = function(obj) {
|
||||
return !!(obj && obj.nodeType == 1);
|
||||
|
||||
Reference in New Issue
Block a user