mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
implement include in terms of detect
This commit is contained in:
@@ -149,15 +149,12 @@
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Determine if a given value is included in the array or object,
|
// Determine if a given value is included in the array or object using '==='.
|
||||||
// based on '==='.
|
|
||||||
_.include = function(obj, target) {
|
_.include = function(obj, target) {
|
||||||
if (obj && _.isFunction(obj.indexOf)) return _.indexOf(obj, target) != -1;
|
if (obj && _.isFunction(obj.indexOf)) return _.indexOf(obj, target) != -1;
|
||||||
var found = false;
|
return !! _.detect(obj, function(value) {
|
||||||
each(obj, function(value) {
|
return value === target;
|
||||||
if (found = value === target) _.breakLoop();
|
|
||||||
});
|
});
|
||||||
return found;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Invoke a method with arguments on every item in a collection.
|
// Invoke a method with arguments on every item in a collection.
|
||||||
|
|||||||
Reference in New Issue
Block a user