From 031aa4367b1fd2267ceecbbeae2ecda98e727b2b Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 1 Dec 2013 14:57:52 +0100 Subject: [PATCH] Ox.toArray -> Ox.slice --- examples/documentation/oxdoc_tutorial/js/example.js | 4 ++-- source/Ox.UI/js/Calendar/Calendar.js | 2 +- source/Ox.UI/js/Core/App.js | 2 +- source/Ox.UI/js/Core/Element.js | 2 +- source/Ox.UI/js/Core/Event.js | 2 +- source/Ox/js/Array.js | 6 +++--- source/Ox/js/Async.js | 10 +++++----- source/Ox/js/Color.js | 4 ++-- source/Ox/js/Core.js | 4 ++-- source/Ox/js/Encoding.js | 2 +- source/Ox/js/Request.js | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/documentation/oxdoc_tutorial/js/example.js b/examples/documentation/oxdoc_tutorial/js/example.js index 004fbfea..81234859 100644 --- a/examples/documentation/oxdoc_tutorial/js/example.js +++ b/examples/documentation/oxdoc_tutorial/js/example.js @@ -296,7 +296,7 @@ My.range Returns a python-style range */ My.range = function() { var a = []; - Ox.loop.apply(null, Ox.toArray(arguments).concat(function(i) { + Ox.loop.apply(null, Ox.slice(arguments).concat(function(i) { a.push(i); })); return a; @@ -358,7 +358,7 @@ My.localStorage = function(ns) { } storage.delete = function() { var keys = arguments.length == 0 ? Object.keys(storage()) - : Ox.toArray(arguments) + : Ox.slice(arguments) keys.forEach(function(key) { delete localStorage[ns + '.' + key]; }); diff --git a/source/Ox.UI/js/Calendar/Calendar.js b/source/Ox.UI/js/Calendar/Calendar.js index 5c87d555..d8f21d2b 100644 --- a/source/Ox.UI/js/Calendar/Calendar.js +++ b/source/Ox.UI/js/Calendar/Calendar.js @@ -1286,7 +1286,7 @@ Ox.Calendar = function(options, self) { {id, {key: value, ...}} -> Calendar object @*/ that.editEvent = function() { - var args = Ox.toArray(arguments), + var args = Ox.slice(arguments), id = args.shift(), data = Ox.makeObject(args), event = Ox.getObjectById(self.options.events, id), diff --git a/source/Ox.UI/js/Core/App.js b/source/Ox.UI/js/Core/App.js index a6890bcf..d00eefc8 100644 --- a/source/Ox.UI/js/Core/App.js +++ b/source/Ox.UI/js/Core/App.js @@ -45,7 +45,7 @@ Ox.App = function(options) { location: {href: location.href}, navigator: { cookieEnabled: navigator.cookieEnabled, - plugins: Ox.toArray(navigator.plugins).map(function(plugin) { + plugins: Ox.slice(navigator.plugins).map(function(plugin) { return plugin.name; }), userAgent: navigator.userAgent diff --git a/source/Ox.UI/js/Core/Element.js b/source/Ox.UI/js/Core/Element.js index 79bc6b90..982fcbbc 100644 --- a/source/Ox.UI/js/Core/Element.js +++ b/source/Ox.UI/js/Core/Element.js @@ -445,7 +445,7 @@ Ox.Element = function(options, self) { @*/ that.toggleOption = function() { var options = {}; - Ox.toArray(arguments).forEach(function(key) { + Ox.slice(arguments).forEach(function(key) { options[key] == !self.options[key]; }); that.options(options); diff --git a/source/Ox.UI/js/Core/Event.js b/source/Ox.UI/js/Core/Event.js index e8a55851..bcadd123 100644 --- a/source/Ox.UI/js/Core/Event.js +++ b/source/Ox.UI/js/Core/Event.js @@ -58,7 +58,7 @@ Ox.Event = (function() { Event names can be namespaced, like `'click.foo'` */ that.bind = function() { - var args = Ox.toArray(arguments), once, self; + var args = Ox.slice(arguments), once, self; if (args.length == 1) { eventHandlers.push(args[0]) } else { diff --git a/source/Ox/js/Array.js b/source/Ox/js/Array.js index bae8dc1c..5b2c1fba 100644 --- a/source/Ox/js/Array.js +++ b/source/Ox/js/Array.js @@ -560,7 +560,7 @@ Ox.makeArray 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 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 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] = []; diff --git a/source/Ox/js/Async.js b/source/Ox/js/Async.js index acca402f..064d1075 100644 --- a/source/Ox/js/Async.js +++ b/source/Ox/js/Async.js @@ -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 diff --git a/source/Ox/js/Color.js b/source/Ox/js/Color.js index 527a1cd0..ce01d81d 100644 --- a/source/Ox/js/Color.js +++ b/source/Ox/js/Color.js @@ -18,7 +18,7 @@ Ox.hsl 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 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; diff --git a/source/Ox/js/Core.js b/source/Ox/js/Core.js index f2e763b5..719f6f1f 100644 --- a/source/Ox/js/Core.js +++ b/source/Ox/js/Core.js @@ -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( diff --git a/source/Ox/js/Encoding.js b/source/Ox/js/Encoding.js index 0f4e66e0..52955ae6 100644 --- a/source/Ox/js/Encoding.js +++ b/source/Ox/js/Encoding.js @@ -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(''); diff --git a/source/Ox/js/Request.js b/source/Ox/js/Request.js index 35eac5d3..caa6fe19 100644 --- a/source/Ox/js/Request.js +++ b/source/Ox/js/Request.js @@ -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;