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
|
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
|
Unlike `Array.prototype.every`, `Ox.every` works for arrays, objects and
|
||||||
strings.
|
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
|
collection <a|o|s> Collection
|
||||||
iterator <f> Iterator
|
iterator <f> Iterator
|
||||||
value <*> Value
|
value <*> Value
|
||||||
|
@ -173,20 +173,22 @@ Ox.forEach = function(collection, iterator, that) {
|
||||||
var i = 0, key, type = Ox.typeOf(collection);
|
var i = 0, key, type = Ox.typeOf(collection);
|
||||||
if (type == 'object' || type == 'storage') {
|
if (type == 'object' || type == 'storage') {
|
||||||
for (key in collection) {
|
for (key in collection) {
|
||||||
if (Ox.hasOwn(collection, key)) {
|
if (
|
||||||
if (iterator.call(that, collection[key], key, collection) === false) {
|
Ox.hasOwn(collection, key)
|
||||||
break;
|
&& iterator.call(that, collection[key], key, collection) === false
|
||||||
}
|
) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
collection = Ox.toArray(collection);
|
collection = Ox.toArray(collection);
|
||||||
for (i = 0; i < collection.length; i++) {
|
for (i = 0; i < collection.length; i++) {
|
||||||
if (i in collection) {
|
if (
|
||||||
if (iterator.call(that, collection[i], i, collection) === false) {
|
i in collection
|
||||||
break;
|
&& iterator.call(that, collection[i], i, collection) === false
|
||||||
}
|
) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,6 +305,8 @@ Ox.max <f> Returns the maximum value of a collection
|
||||||
3
|
3
|
||||||
> Ox.max('123')
|
> Ox.max('123')
|
||||||
3
|
3
|
||||||
|
> Ox.max([])
|
||||||
|
-Infinity
|
||||||
@*/
|
@*/
|
||||||
Ox.max = function(collection) {
|
Ox.max = function(collection) {
|
||||||
var ret, values = Ox.values(collection);
|
var ret, values = Ox.values(collection);
|
||||||
|
@ -324,6 +328,8 @@ Ox.min <f> Returns the minimum value of a collection
|
||||||
1
|
1
|
||||||
> Ox.min('123')
|
> Ox.min('123')
|
||||||
1
|
1
|
||||||
|
> Ox.min([])
|
||||||
|
Infinity
|
||||||
@*/
|
@*/
|
||||||
Ox.min = function(collection) {
|
Ox.min = function(collection) {
|
||||||
var ret, values = Ox.values(collection);
|
var ret, values = Ox.values(collection);
|
||||||
|
@ -468,7 +474,7 @@ Ox.objectToArray = function(object, key) {
|
||||||
Ox.forEach(object, function(v, k) {
|
Ox.forEach(object, function(v, k) {
|
||||||
ret.push(Ox.extend(v, key, k));
|
ret.push(Ox.extend(v, key, k));
|
||||||
});
|
});
|
||||||
return ret
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue