faster Ox.every
This commit is contained in:
parent
75b5b76157
commit
8abbbd4791
1 changed files with 5 additions and 4 deletions
|
@ -106,15 +106,16 @@ Ox.every <f> Tests if every element of a collection satisfies a given condition
|
|||
true
|
||||
> Ox.every({a: 1, b: 2, c: 3}, function(v) { return v == 1; })
|
||||
false
|
||||
> Ox.every("foo", function(v) { return v == 'f'; })
|
||||
> Ox.every('foo', function(v) { return v == 'f'; })
|
||||
false
|
||||
> Ox.every([true, true, true])
|
||||
true
|
||||
@*/
|
||||
Ox.every = function(collection, iterator, that) {
|
||||
return Ox.filter(
|
||||
Ox.values(collection), iterator || Ox.identity, that
|
||||
).length == Ox.len(collection);
|
||||
iterator = iterator || Ox.identity;
|
||||
return Ox.forEach(collection, function(value, key, collection) {
|
||||
return !!iterator.call(that, value, key, collection);
|
||||
}) == Ox.len(collection);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
Loading…
Reference in a new issue