avoid double 'if' in Ox.forEach; minor documentation cleanup
This commit is contained in:
parent
67f744baaf
commit
0d9f689605
1 changed files with 16 additions and 10 deletions
|
@ -95,7 +95,7 @@ Ox.count = function(collection, value) {
|
|||
Ox.every <f> Tests if every element of a collection satisfies a given condition
|
||||
Unlike `Array.prototype.every`, `Ox.every` works for arrays, objects and
|
||||
strings.
|
||||
(collection, iterator) -> <b> True if every element passes the test
|
||||
(collection[, iterator]) -> <b> True if every element passes the test
|
||||
collection <a|o|s> Collection
|
||||
iterator <f> Iterator
|
||||
value <*> Value
|
||||
|
@ -173,20 +173,22 @@ Ox.forEach = function(collection, iterator, that) {
|
|||
var i = 0, key, type = Ox.typeOf(collection);
|
||||
if (type == 'object' || type == 'storage') {
|
||||
for (key in collection) {
|
||||
if (Ox.hasOwn(collection, key)) {
|
||||
if (iterator.call(that, collection[key], key, collection) === false) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
Ox.hasOwn(collection, key)
|
||||
&& iterator.call(that, collection[key], key, collection) === false
|
||||
) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
collection = Ox.toArray(collection);
|
||||
for (i = 0; i < collection.length; i++) {
|
||||
if (i in collection) {
|
||||
if (iterator.call(that, collection[i], i, collection) === false) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
i in collection
|
||||
&& iterator.call(that, collection[i], i, collection) === false
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,6 +305,8 @@ Ox.max <f> Returns the maximum value of a collection
|
|||
3
|
||||
> Ox.max('123')
|
||||
3
|
||||
> Ox.max([])
|
||||
-Infinity
|
||||
@*/
|
||||
Ox.max = function(collection) {
|
||||
var ret, values = Ox.values(collection);
|
||||
|
@ -324,6 +328,8 @@ Ox.min <f> Returns the minimum value of a collection
|
|||
1
|
||||
> Ox.min('123')
|
||||
1
|
||||
> Ox.min([])
|
||||
Infinity
|
||||
@*/
|
||||
Ox.min = function(collection) {
|
||||
var ret, values = Ox.values(collection);
|
||||
|
@ -468,7 +474,7 @@ Ox.objectToArray = function(object, key) {
|
|||
Ox.forEach(object, function(v, k) {
|
||||
ret.push(Ox.extend(v, key, k));
|
||||
});
|
||||
return ret
|
||||
return ret;
|
||||
};
|
||||
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue