From f6b06d097506f12e959fa53709f9a0180da467a9 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 24 May 2012 12:19:23 +0200 Subject: [PATCH] throw error when returning false in Ox.forEach; remove Ox.sub --- source/Ox/js/Collection.js | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/source/Ox/js/Collection.js b/source/Ox/js/Collection.js index 70b9a873..4ae72d89 100644 --- a/source/Ox/js/Collection.js +++ b/source/Ox/js/Collection.js @@ -183,16 +183,14 @@ Ox.forEach = function(col, fn, that) { for (key in col) { // Ox.hasOwn(obj, key) && fn.call(that, col[key], key, col); if (Ox.hasOwn(col, key) && fn.call(that, col[key], key, col) === false) { - console.warn('Returning false in Ox.forEach is deprecated.') - break; + throw new Error('Returning false in Ox.forEach is deprecated.'); } } } else { for (i = 0; i < col.length; i++) { // i in col && fn.call(that, col[i], i, col); if (i in col && fn.call(that, col[i], i, col) === false) { - console.warn('Returning false in Ox.forEach is deprecated.') - break; + throw new Error('Returning false in Ox.forEach is deprecated.'); } } } @@ -624,36 +622,6 @@ Ox.some = function(obj, fn) { }).length > 0; }; -/*@ -Ox.sub Returns a substring or sub-array - Ox.sub behaves like collection[start:stop] in Python - (or, for strings, like str.substring() with negative values for stop) - > Ox.sub([1, 2, 3], 1, -1) - [2] - > Ox.sub('foobar', 1) - "oobar" - > Ox.sub('foobar', -1) - "r" - > Ox.sub('foobar', 1, 5) - "ooba" - > Ox.sub('foobar', 1, -1) - "ooba" - > Ox.sub('foobar', -5, 5) - "ooba" - > Ox.sub('foobar', -5, -1) - "ooba" - > Ox.sub('foo', -1, 0) - "" -@*/ -Ox.sub = function(col, start, stop) { - stop = Ox.isUndefined(stop) ? col.length : stop; - start = start < 0 ? col.length + start : start; - stop = stop < 0 ? col.length + stop : stop; - return Ox.isArray(col) ? Ox.filter(col, function(val, key) { - return key >= start && key < stop; - }) : col.substring(start, Math.max(start, stop)); -} - /*@ Ox.sum Returns the sum of the values of a collection > Ox.sum(1, 2, 3)