faster Ox.some
This commit is contained in:
parent
1b90cc6ac8
commit
c083516fad
1 changed files with 9 additions and 2 deletions
|
@ -507,8 +507,15 @@ Ox.some <f> Tests if one or more elements of a collection meet a given condition
|
||||||
false
|
false
|
||||||
@*/
|
@*/
|
||||||
Ox.some = function(collection, iterator) {
|
Ox.some = function(collection, iterator) {
|
||||||
// FIXME: use forEach and break!
|
iterator = iterator || Ox.identity;
|
||||||
return Ox.filter(Ox.values(collection), iterator || Ox.identity).length > 0;
|
var ret = false;
|
||||||
|
Ox.forEach(collection, function(value, key, collection) {
|
||||||
|
if (iterator(value, key, collection)) {
|
||||||
|
ret = true;
|
||||||
|
return false; // break
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
|
|
Loading…
Reference in a new issue