From c083516fada89046a547ba8342e9a0fc0394946d Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 19 Aug 2014 13:51:29 +0200 Subject: [PATCH] faster Ox.some --- source/Ox/js/Collection.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/Ox/js/Collection.js b/source/Ox/js/Collection.js index 7a446d1f..a2b41404 100644 --- a/source/Ox/js/Collection.js +++ b/source/Ox/js/Collection.js @@ -507,8 +507,15 @@ Ox.some Tests if one or more elements of a collection meet a given condition false @*/ Ox.some = function(collection, iterator) { - // FIXME: use forEach and break! - return Ox.filter(Ox.values(collection), iterator || Ox.identity).length > 0; + iterator = iterator || Ox.identity; + var ret = false; + Ox.forEach(collection, function(value, key, collection) { + if (iterator(value, key, collection)) { + ret = true; + return false; // break + } + }); + return ret; }; /*@