Module:Shared: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 92: Line 92:
end
end
end
end
end
-- Makes a deep copy of a table or otherwise object.
-- Yoinked from http://lua-users.org/wiki/CopyTable
function p.deepcopy(orig)
    local copy
    if type(orig) == 'table' then
        copy = {}
        for orig_key, orig_value in next, orig, nil do
            copy[deepcopy(orig_key)] = deepcopy(orig_value)
        end
        setmetatable(copy, deepcopy(getmetatable(orig)))
    else -- number, string, boolean, etc
        copy = orig
    end
    return copy
end
end


Line 126: Line 142:
-- specialTitleCase('amulet Of Fishing') = 'Amulet of Fishing'
-- specialTitleCase('amulet Of Fishing') = 'Amulet of Fishing'
function p.specialTitleCase(sentence)
function p.specialTitleCase(sentence)
if sentence == nil or sentence:match("^%s*$") ~= nil then return nil end
-- List of words that are excluded from TitleCase
-- List of words that are excluded from TitleCase
     local excludedWords = {
     local excludedWords = {
1,029

edits