Module:Sandbox/Ahecht/wikibase

require('strict')
return setmetatable({}, {
	__index = function(t, k)
		local what = mw.wikibase[k]
		if type(what) ~= "function" then
			return what
		end
		return function(frame)
			local fargs = frame.args
			local args = {}
			local str_i = 1
			while fargs['s' .. str_i] do
				args[str_i] = fargs['s' .. str_i]
				str_i = str_i + 1
			end
			for i, v in ipairs(fargs) do
				args[i + str_i - 1] = tonumber(v) or v:gsub("^\\", "", 1)
			end
			return (what(unpack(args)))		-- Outside parens truncate to first result avoiding tail call
		end
	end
})