mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Added lume.combine() function
This commit is contained in:
parent
335b928cae
commit
5db6be936a
13
lume.lua
13
lume.lua
@ -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(...)}
|
||||||
|
Loading…
Reference in New Issue
Block a user