add comment; remove separate Ox.toArray

This commit is contained in:
rolux 2013-11-29 21:15:36 +01:00
parent d9b25c6fae
commit 84bfd1222e

View file

@ -556,6 +556,7 @@ Ox.makeArray <f> Wraps any non-array in an array.
> Ox.makeArray(['foo']) > Ox.makeArray(['foo'])
['foo'] ['foo']
@*/ @*/
// FIXME: rename to toArray
Ox.makeArray = function(value) { Ox.makeArray = function(value) {
var ret, type = Ox.typeOf(value); var ret, type = Ox.typeOf(value);
if (type == 'arguments') { if (type == 'arguments') {
@ -738,38 +739,6 @@ Ox.range = function() {
}()); }());
/*@
Ox.toArray <f> Takes an array-like object and returns a true array
(value) -> <a> True array
value <*> Array-like object
> (function() { return Ox.toArray(arguments); }('foo', 'bar'))
['foo', 'bar']
> Ox.toArray('foo')
['f', 'o', 'o']
> Ox.toArray({0: 'f', 1: 'o', 2: 'o', length: 3})
['f', 'o', 'o']
@*/
Ox.toArray = function(collection) {
return Ox.slice(collection);
};
try {
Array.prototype.slice.call(document.getElementsByTagName('a'));
} catch (error) {
// Handle IE NodeLists
Ox.toArray = function(collection) {
var i, length, ret = [];
try {
ret = Ox.slice(collection);
} catch (error) {
length = collection.length;
for (i = 0; i < length; i++) {
ret[i] = collection[i];
}
}
return ret;
};
}
/*@ /*@
Ox.unique <f> Removes duplicate values from an array Ox.unique <f> Removes duplicate values from an array
(array) -> <a> Array without duplicate values (array) -> <a> Array without duplicate values