Changes

no edit summary
Line 30: Line 30:  
end
 
end
 
return r
 
return r
 +
end
 +
 +
function Utils.size(xs)
 +
local r = 0
 +
for _ in pairs(xs) do
 +
r = r + 1
 +
end
 +
return r
 +
end
 +
 +
function Utils.removekey(xs, k)
 +
local e = xs[k]
 +
xs[k] = nil
 +
return e
 
end
 
end
   Line 212: Line 226:  
end
 
end
   −
function Utils.isort(arr)
+
function Utils.sort(tbl, f)
 +
    table.sort(tbl, f)
 +
    return tbl
 +
end
 +
 
 +
function Utils.isort(arr, f)
 
     local result = Utils.icopy(arr)
 
     local result = Utils.icopy(arr)
     table.sort(result)
+
     table.sort(result, f)
 
     return result
 
     return result
 
end
 
end
Line 325: Line 344:  
     local success, data = pcall(function () return require(string.format("Module:%s", name)) end)
 
     local success, data = pcall(function () return require(string.format("Module:%s", name)) end)
 
     -- module without return (or empty, nil, false, true return) gives success = true, data = true
 
     -- module without return (or empty, nil, false, true return) gives success = true, data = true
 +
    if data == true then
 +
        return false, nil
 +
    else
 +
        return success, data
 +
    end
 +
end
 +
 +
function Utils.loadData(name)
 +
    local success, data = pcall(function () return mw.loadData(string.format("Module:%s", name)) end)
 +
    -- TODO: ???
 
     if data == true then
 
     if data == true then
 
         return false, nil
 
         return false, nil
cssedit, gkautomate
6,926

edits