మాడ్యూల్:Arguments: కూర్పుల మధ్య తేడాలు

Content deleted Content added
చి en:Module:Arguments నుండి ఒక కూర్పు
apply changes from sandbox - all tests pass
పంక్తి 46:
local function tidyValNoChange(key, val)
return val
end
 
local function matchesTitle(given, title)
local tp = type( given )
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end
 
Line 82 ⟶ 87:
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if typematchesTitle(options.wrappers, title) == 'table' then
found = true
elseif type(options.wrappers) == title'table' then
for _,v in pairs(options.wrappers) do
if matchesTitle(v ==, title) then
found = true
break
end
end
elseif options.wrappers == title then
found = true
end
Line 165 ⟶ 170:
setmetatable(args, metatable)
 
local function mergeArgs(iterator, tables)
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table using the specified iterator. If a value is already present it is not overwritten;
-- present it is not overwritten; tables listed earlier have precedence. We are also memoizing nil
-- We are also memoizing nil values, which can be overwritten if they are 's' (soft).
-- are 's' (soft).
--]]
for _, t in ipairs(tables) do
for key, val in iteratorpairs(t) do
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
Line 263 ⟶ 267:
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(pairs, argTables)
metatable.donePairs = true
metatable.doneIpairs = true
end
return pairs(metaArgs)
end
local function inext(t, i)
-- This uses our __index metamethod
local v = t[i + 1]
if v ~= nil then
return i + 1, v
end
end
 
metatable.__ipairs = function (t)
-- Called when ipairs is run on the args table.
return inext, t, 0
if not metatable.doneIpairs then
mergeArgs(ipairs, argTables)
metatable.doneIpairs = true
end
return ipairs(metaArgs)
end
 
"https://te.wikipedia.org/wiki/మాడ్యూల్:Arguments" నుండి వెలికితీశారు