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
|
true
|
||||||
> Ox.every({a: 1, b: 2, c: 3}, function(v) { return v == 1; })
|
> Ox.every({a: 1, b: 2, c: 3}, function(v) { return v == 1; })
|
||||||
false
|
false
|
||||||
> Ox.every("foo", function(v) { return v == 'f'; })
|
> Ox.every('foo', function(v) { return v == 'f'; })
|
||||||
false
|
false
|
||||||
> Ox.every([true, true, true])
|
> Ox.every([true, true, true])
|
||||||
true
|
true
|
||||||
@*/
|
@*/
|
||||||
Ox.every = function(collection, iterator, that) {
|
Ox.every = function(collection, iterator, that) {
|
||||||
return Ox.filter(
|
iterator = iterator || Ox.identity;
|
||||||
Ox.values(collection), iterator || Ox.identity, that
|
return Ox.forEach(collection, function(value, key, collection) {
|
||||||
).length == Ox.len(collection);
|
return !!iterator.call(that, value, key, collection);
|
||||||
|
}) == Ox.len(collection);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
|
|
Loading…
Reference in a new issue