modify comment for Ox.slice, use Ox.slice
This commit is contained in:
parent
ab3711cfad
commit
137124a903
1 changed files with 9 additions and 9 deletions
|
@ -138,7 +138,7 @@ Ox.filter = function(collection, iterator, that) {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
ret = Ox.toArray(collection).filter(iterator, that);
|
||||
ret = Ox.slice(collection).filter(iterator, that);
|
||||
if (type == 'string') {
|
||||
ret = ret.join('');
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ Ox.forEach = function(collection, iterator, that) {
|
|||
i++;
|
||||
}
|
||||
} else {
|
||||
collection = Ox.toArray(collection);
|
||||
collection = Ox.slice(collection);
|
||||
for (i = 0; i < collection.length; i++) {
|
||||
if (
|
||||
i in collection
|
||||
|
@ -289,7 +289,7 @@ Ox.map = function(collection, iterator, that) {
|
|||
ret[key] = iterator.call(that, value, key, collection);
|
||||
});
|
||||
} else {
|
||||
ret = Ox.toArray(collection).map(iterator);
|
||||
ret = Ox.slice(collection).map(iterator);
|
||||
if (type == 'string') {
|
||||
ret = ret.join('');
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ Ox.shuffle = function(collection) {
|
|||
});
|
||||
} else {
|
||||
ret = [];
|
||||
Ox.toArray(collection).forEach(function(value, index) {
|
||||
Ox.slice(collection).forEach(function(value, index) {
|
||||
var random = Math.floor(Math.random() * (index + 1));
|
||||
ret[index] = ret[random];
|
||||
ret[random] = value;
|
||||
|
@ -459,10 +459,10 @@ Ox.slice <f> Alias for `Array.prototype.slice.call`
|
|||
Ox.slice = Ox.toArray = function(collection, start, stop) {
|
||||
return Array.prototype.slice.call(collection, start, stop);
|
||||
};
|
||||
// IE8 returns an empty array if undefined is passed as stop
|
||||
// and an array of null values if a string is passed as value.
|
||||
// Firefox 3.6 returns an array of undefined values if a string
|
||||
// is passed as value. IE NodeLists may not work with slice.
|
||||
// IE8 can't apply slice to NodeLists, returns an empty array if undefined is
|
||||
// passed as stop and returns an array of null values if a string is passed as
|
||||
// value. Firefox 3.6 returns an array of undefined values if a string is passed
|
||||
// as value.
|
||||
if (
|
||||
Ox.slice([0]).length == 0
|
||||
|| Ox.slice('0')[0] === null
|
||||
|
@ -527,7 +527,7 @@ Ox.sum <f> Returns the sum of the values of a collection
|
|||
@*/
|
||||
Ox.sum = function(collection) {
|
||||
var ret = 0;
|
||||
collection = arguments.length > 1 ? Ox.toArray(arguments) : collection;
|
||||
collection = arguments.length > 1 ? Ox.slice(arguments) : collection;
|
||||
Ox.forEach(collection, function(value) {
|
||||
value = +value;
|
||||
ret += isFinite(value) ? value : 0;
|
||||
|
|
Loading…
Reference in a new issue