Module:Existsmod/sandbox

-- Checks if a module exists (not an expensive call) -- Syntax : -- →-- local p = {}

function p.module_exists(oArgTable) local name,action1,action2 = "" local u = require("Module:Utility") local args,cArgs = u.getArgs(oArgTable,"both") local function getParams(argName) if args and args[argName] then return args[argName] else if (cArgs and cArgs[argName]) then return cArgs[argName] end end end if type(oArgTable)=="table" then name   = getParams(1) or getParams("name") action1 = getParams(2) action2 = getParams(3) end if type (oArgTable) == "string" then name = oArgTable end if name and not name:match(":") then name = "Module:"..name end if name and package.loaded[name] then return action1 or true else for _, searcher in ipairs(package.searchers or package.loaders) do           local loader = searcher(name) if type(loader) == 'function' then return action1 or true end end return action2 or false end end

function p.main(frame) return p.module_exists(frame) end

return p