-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmergeLibs.lua
More file actions
31 lines (16 loc) · 778 Bytes
/
mergeLibs.lua
File metadata and controls
31 lines (16 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--[[
Returns a table that contains some lib functions ( like the Lua table and string tables )
from index number key values and adds any other functions that have a string key.
]]
local astro = Astro.Type local isString = astro.isString local isNumber = astro.isNumber
local isFunction = astro.isFunction
return function( input, lib )
local t = {}
local function add( k, v )
local isValid1 = isNumber(k) and isString(v)
local isValid2 = isString(k) and isFunction(v)
local isValid = isValid1 or isValid2 if not isValid then return end
if isValid1 then k = v v = lib[v] end t[k] = v
end
for k,v in pairs(input) do add( k, v ) end return t
end