mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Stripped all trailing whitespace
This commit is contained in:
parent
5ab25046a2
commit
17b58ec63d
16
lume.lua
16
lume.lua
@ -136,7 +136,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function lume.map(t, fn)
|
function lume.map(t, fn)
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
for k, v in pairs(t) do rtn[k] = fn(v) end
|
for k, v in pairs(t) do rtn[k] = fn(v) end
|
||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
@ -170,7 +170,7 @@ end
|
|||||||
|
|
||||||
function lume.set(t, retainkeys)
|
function lume.set(t, retainkeys)
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
for k, v in pairs(lume.invert(t)) do
|
for k, v in pairs(lume.invert(t)) do
|
||||||
rtn[retainkeys and v or (#rtn + 1)] = k
|
rtn[retainkeys and v or (#rtn + 1)] = k
|
||||||
end
|
end
|
||||||
return rtn
|
return rtn
|
||||||
@ -253,7 +253,7 @@ function lume.fn(fn, ...)
|
|||||||
local args = {...}
|
local args = {...}
|
||||||
return function(...)
|
return function(...)
|
||||||
local a = lume.merge(lume.clone(args), {...})
|
local a = lume.merge(lume.clone(args), {...})
|
||||||
return fn(unpack(a))
|
return fn(unpack(a))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -363,8 +363,8 @@ end
|
|||||||
|
|
||||||
function lume.format(str, vars)
|
function lume.format(str, vars)
|
||||||
if not vars then return str end
|
if not vars then return str end
|
||||||
local f = function(x)
|
local f = function(x)
|
||||||
return tostring(vars[x] or vars[tonumber(x)] or "{" .. x .. "}")
|
return tostring(vars[x] or vars[tonumber(x)] or "{" .. x .. "}")
|
||||||
end
|
end
|
||||||
return (str:gsub("{(.-)}", f))
|
return (str:gsub("{(.-)}", f))
|
||||||
end
|
end
|
||||||
@ -401,7 +401,7 @@ function lume.hotswap(modname)
|
|||||||
local oldglobal = lume.clone(_G)
|
local oldglobal = lume.clone(_G)
|
||||||
local updated = {}
|
local updated = {}
|
||||||
local function update(old, new)
|
local function update(old, new)
|
||||||
if updated[old] then return end
|
if updated[old] then return end
|
||||||
updated[old] = true
|
updated[old] = true
|
||||||
local oldmt, newmt = getmetatable(old), getmetatable(new)
|
local oldmt, newmt = getmetatable(old), getmetatable(new)
|
||||||
if oldmt and newmt then update(oldmt, newmt) end
|
if oldmt and newmt then update(oldmt, newmt) end
|
||||||
@ -421,7 +421,7 @@ function lume.hotswap(modname)
|
|||||||
local newmod = require(modname)
|
local newmod = require(modname)
|
||||||
if type(oldmod) == "table" then update(oldmod, newmod) end
|
if type(oldmod) == "table" then update(oldmod, newmod) end
|
||||||
for k, v in pairs(oldglobal) do
|
for k, v in pairs(oldglobal) do
|
||||||
if v ~= _G[k] and type(v) == "table" then
|
if v ~= _G[k] and type(v) == "table" then
|
||||||
update(v, _G[k])
|
update(v, _G[k])
|
||||||
_G[k] = v
|
_G[k] = v
|
||||||
end
|
end
|
||||||
@ -457,4 +457,4 @@ function lume.chain(value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return lume
|
return lume
|
Loading…
Reference in New Issue
Block a user