Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (24 sloc) 0.784 kb
-- 'desire' functions similarly to 'require', save that failure is not an error.
-- use this if you can make use of a modules features, but can make do without.
--
-- if successful it returns the same value that require would return
-- (either true, or the actual module table) if unsuccessful, it returns
-- false, and a string indicating the error.
function desire(name, ...)
local p, m, err = pcall(require, n, ...)
if p then
return m
else -- p == false
return p, m
end
end
-- inquire determines if a package is loaded.
-- if so, it returns the value that 'require' would return.
-- otherwise, it returns false and the string "not loaded"
function inquire(name, ...)
if package.loaded[name] then
return package.loaded[name]
else
return false, "not loaded"
end
end
Jump to Line
Something went wrong with that request. Please try again.