Ox.toArray -> Ox.slice
This commit is contained in:
parent
3a28b08d46
commit
031aa4367b
11 changed files with 20 additions and 20 deletions
|
|
@ -560,7 +560,7 @@ Ox.makeArray <f> Wraps any non-array in an array.
|
|||
Ox.makeArray = function(value) {
|
||||
var ret, type = Ox.typeOf(value);
|
||||
if (type == 'arguments') {
|
||||
ret = Ox.toArray(value);
|
||||
ret = Ox.slice(value);
|
||||
} else if (type == 'array') {
|
||||
ret = value;
|
||||
} else {
|
||||
|
|
@ -624,7 +624,7 @@ Ox.range <f> Python-style range
|
|||
@*/
|
||||
Ox.range = function() {
|
||||
var array = [];
|
||||
Ox.loop.apply(null, Ox.toArray(arguments).concat(function(index) {
|
||||
Ox.loop.apply(null, Ox.slice(arguments).concat(function(index) {
|
||||
array.push(index);
|
||||
}));
|
||||
return array;
|
||||
|
|
@ -761,7 +761,7 @@ Ox.zip <f> Zips an array of arrays
|
|||
[[0, 3], [1, 4], [2, 5]]
|
||||
@*/
|
||||
Ox.zip = function() {
|
||||
var args = arguments.length == 1 ? arguments[0] : Ox.toArray(arguments),
|
||||
var args = arguments.length == 1 ? arguments[0] : Ox.slice(arguments),
|
||||
array = [];
|
||||
args[0].forEach(function(value, index) {
|
||||
array[index] = [];
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
n, time, type = Ox.typeOf(collection);
|
||||
callback = Ox.isFunction(last) ? last : arguments[arguments.length - 2];
|
||||
collection = type == 'array' || type == 'object'
|
||||
? collection : Ox.toArray(collection);
|
||||
? collection : Ox.slice(collection);
|
||||
keys = type == 'object'
|
||||
? Object.keys(collection) : Ox.range(collection.length);
|
||||
ms = ms || 1000;
|
||||
|
|
@ -149,7 +149,7 @@
|
|||
var i = 0, n, type = Ox.typeOf(collection);
|
||||
callback = callback || (arguments.length == 3 ? arguments[2] : Ox.noop);
|
||||
collection = type == 'array' || type == 'object'
|
||||
? collection : Ox.toArray(collection);
|
||||
? collection : Ox.slice(collection);
|
||||
n = Ox.len(collection);
|
||||
that = arguments.length == 4 ? that : null;
|
||||
Ox.forEach(collection, function(value, key, collection) {
|
||||
|
|
@ -192,7 +192,7 @@
|
|||
undefined
|
||||
@*/
|
||||
Ox.parallelMap = function() {
|
||||
asyncMap.apply(null, [Ox.parallelForEach].concat(Ox.toArray(arguments)));
|
||||
asyncMap.apply(null, [Ox.parallelForEach].concat(Ox.slice(arguments)));
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
@ -222,7 +222,7 @@
|
|||
var i = 0, keys, n, type = Ox.typeOf(collection);
|
||||
callback = callback || (arguments.length == 3 ? arguments[2] : Ox.noop);
|
||||
collection = type == 'array' || type == 'object'
|
||||
? collection : Ox.toArray(collection);
|
||||
? collection : Ox.slice(collection);
|
||||
keys = type == 'object'
|
||||
? Object.keys(collection) : Ox.range(collection.length);
|
||||
n = Ox.len(collection);
|
||||
|
|
@ -280,7 +280,7 @@
|
|||
undefined
|
||||
@*/
|
||||
Ox.serialMap = function(collection, iterator, that, callback) {
|
||||
asyncMap.apply(null, [Ox.serialForEach].concat(Ox.toArray(arguments)));
|
||||
asyncMap.apply(null, [Ox.serialForEach].concat(Ox.slice(arguments)));
|
||||
};
|
||||
// FIXME: The above test with 10000 iterations blows the stack
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Ox.hsl <f> Takes RGB values and returns HSL values
|
|||
Ox.hsl = function(rgb) {
|
||||
var hsl = [0, 0, 0], max, min;
|
||||
if (arguments.length == 3) {
|
||||
rgb = Ox.toArray(arguments);
|
||||
rgb = Ox.slice(arguments);
|
||||
}
|
||||
rgb = Ox.clone(rgb).map(function(value) {
|
||||
return value / 255;
|
||||
|
|
@ -65,7 +65,7 @@ Ox.rgb <f> Takes HSL values and returns RGB values
|
|||
Ox.rgb = function(hsl) {
|
||||
var rgb = [0, 0, 0], v1, v2, v3;
|
||||
if (arguments.length == 3) {
|
||||
hsl = Ox.toArray(arguments);
|
||||
hsl = Ox.slice(arguments);
|
||||
}
|
||||
hsl = Ox.clone(hsl);
|
||||
hsl[0] /= 360;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ Ox.localStorage = function(namespace) {
|
|||
// IE 8 doesn't like `storage.delete`
|
||||
storage['delete'] = function() {
|
||||
var keys = arguments.length == 0 ? Object.keys(storage())
|
||||
: Ox.toArray(arguments)
|
||||
: Ox.slice(arguments)
|
||||
keys.forEach(function(key) {
|
||||
delete localStorage[namespace + '.' + key];
|
||||
});
|
||||
|
|
@ -173,7 +173,7 @@ Ox.Log = (function() {
|
|||
}));
|
||||
};
|
||||
that.log = function() {
|
||||
var args = Ox.toArray(arguments), date, ret;
|
||||
var args = Ox.slice(arguments), date, ret;
|
||||
if (!log.filterEnabled || log.filter.indexOf(args[0]) > -1) {
|
||||
date = new Date();
|
||||
args.unshift(
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ Ox.decodeDeflate = function(string, callback) {
|
|||
// Unfortunately, we can't synchronously set the source of an image,
|
||||
// draw it onto a canvas, and read its data.
|
||||
image.onload = function() {
|
||||
string = Ox.toArray(Ox.canvas(image).data).map(function(value, index) {
|
||||
string = Ox.slice(Ox.canvas(image).data).map(function(value, index) {
|
||||
// Read one character per RGB byte, ignore ALPHA.
|
||||
return index % 4 < 3 ? Ox.char(value) : '';
|
||||
}).join('');
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ Ox.getFile = (function() {
|
|||
}
|
||||
}
|
||||
function findFileInHead() {
|
||||
return Ox.toArray(
|
||||
return Ox.slice(
|
||||
document.getElementsByTagName(type == 'css' ? 'link' : 'script')
|
||||
).map(function(element) {
|
||||
return element[type == 'css' ? 'href' : 'src'] == file;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue