avoid double 'if' in Ox.forEach; minor documentation cleanup

This commit is contained in:
rolux 2013-01-03 15:56:55 +01:00
parent 67f744baaf
commit 0d9f689605

View file

@ -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;
};
*/