1
0
Fork 0
mirror of https://github.com/Reuh/candran.git synced 2025-10-28 10:19:30 +00:00

Rename lib to candran

This commit is contained in:
Étienne Fildadut 2020-01-19 15:36:25 +01:00
parent 5fff7612f4
commit dc19ac56a9
13 changed files with 2007 additions and 2000 deletions

40
candran/util.can Normal file
View file

@ -0,0 +1,40 @@
local util = {}
function util.search(modpath, exts={})
for _, ext in ipairs(exts) do
for path in package.path:gmatch("[^;]+") do
local fpath = path:gsub("%.lua", "."..ext):gsub("%?", (modpath:gsub("%.", "/")))
local f = io.open(fpath)
if f then
f:close()
return fpath
end
end
end
end
function util.load(str, name, env)
if _VERSION == "Lua 5.1" then
local fn, err = loadstring(str, name)
if not fn then return fn, err end
return env ~= nil and setfenv(fn, env) or fn
else
if env then
return load(str, name, nil, env)
else
return load(str, name)
end
end
end
function util.merge(...)
local r = {}
for _, t in ipairs({...}) do
for k, v in pairs(t) do
r[k] = v
end
end
return r
end
return util