Added lume.combine() function

This commit is contained in:
rxi 2014-04-03 20:09:40 +01:00
parent 335b928cae
commit 5db6be936a

View File

@ -31,6 +31,10 @@ local absindex = function(len, i)
return i < 0 and (len + i + 1) or i return i < 0 and (len + i + 1) or i
end end
local isfunction = function(x)
return type(x) == "function"
end
function lume.clamp(x, min, max) function lume.clamp(x, min, max)
return x < min and min or (x > max and max or x) return x < min and min or (x > max and max or x)
@ -242,6 +246,15 @@ function lume.once(fn, ...)
end end
function lume.combine(...)
local funcs = {...}
assert(lume.all(funcs, isfunction), "expected all arguments to be functions")
return function(...)
for _, f in ipairs(funcs) do f(...) end
end
end
function lume.time(fn, ...) function lume.time(fn, ...)
local start = os.clock() local start = os.clock()
local rtn = {fn(...)} local rtn = {fn(...)}