From 16e370cdf02e6a1b7aa06c56f0964a9c036b3b13 Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 12 Dec 2014 19:45:22 +0000 Subject: [PATCH] Changed all applicable functions to use iteratee() internally --- lume.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lume.lua b/lume.lua index c868992..18d38cc 100644 --- a/lume.lua +++ b/lume.lua @@ -155,6 +155,7 @@ end function lume.map(t, fn) + fn = iteratee(fn) local rtn = {} for k, v in pairs(t) do rtn[k] = fn(v) end return rtn @@ -162,7 +163,7 @@ end function lume.all(t, fn) - fn = fn or function(x) return x end + fn = iteratee(fn) for k, v in pairs(t) do if not fn(v) then return false end end @@ -171,7 +172,7 @@ end function lume.any(t, fn) - fn = fn or function(x) return x end + fn = iteratee(fn) for k, v in pairs(t) do if fn(v) then return true end end @@ -197,6 +198,7 @@ end function lume.filter(t, fn, retainkeys) + fn = iteratee(fn) local rtn = {} for k, v in pairs(t) do if fn(v) then rtn[retainkeys and k or (#rtn + 1)] = v end @@ -222,6 +224,7 @@ end function lume.match(t, fn) + fn = iteratee(fn) for k, v in pairs(t) do if fn(v) then return v, k end end @@ -232,6 +235,7 @@ end function lume.count(t, fn) local count = 0 if fn then + fn = iteratee(fn) for k, v in pairs(t) do if fn(v) then count = count + 1 end end