Skip to content

Commit

Permalink
whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Johnson committed Aug 3, 2011
1 parent 12dcb01 commit 6c1e726
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
44 changes: 22 additions & 22 deletions lib/stdlib/ext/table.lua
@@ -1,28 +1,28 @@
function table.clone(t, nometa)
local u = {}

if not nometa then
setmetatable(u, getmetatable(t))
end

for i, v in pairs(t) do
if type(v) == "table" then
u[i] = table.clone(v)
else
u[i] = v
end
end

return u
end

function table.merge(t, u)
local r = table.clone(t)

for i, v in pairs(u) do
r[i] = v
end

return r
end

Expand All @@ -42,8 +42,8 @@ function table.unique(t)
end

function table.values(t)
local values = {}
for k, v in pairs(t) do table.insert(values, v) end
local values = {}
for k, v in pairs(t) do table.insert(values, v) end
return values
end

Expand All @@ -55,7 +55,7 @@ function table.append(t, moreValues)
for i, v in ipairs(moreValues) do
table.insert(t, v)
end

return t
end

Expand All @@ -67,7 +67,7 @@ function table.indexOf(t, value)
if v == value then return k end
end
end

return nil
end

Expand All @@ -83,15 +83,15 @@ end

function table.each(t, func)
for k, v in pairs(t) do
func(v)
end
func(v, k)
end
end

function table.find(t, func)
for k, v in pairs(t) do
if func(v) then return v, k end
end

return nil
end

Expand All @@ -100,7 +100,7 @@ function table.filter(t, func)
for k, v in pairs(t) do
if func(v) then table.insert(matches, v) end
end

return matches
end

Expand All @@ -109,18 +109,18 @@ function table.map(t, func)
for k, v in pairs(t) do
table.insert(mapped, func(v, k))
end

return mapped
end

function table.groupBy(t, func)
local grouped = {}
for k, v in pairs(t) do
local groupKey = func(v)
if not grouped[groupKey] then grouped[groupKey] = {} end
if not grouped[groupKey] then grouped[groupKey] = {} end
table.insert(grouped[groupKey], v)
end

return grouped
end

Expand All @@ -139,27 +139,27 @@ function table.tostring(tbl, indent, limit, depth, jstack)
end
end
table.insert(jstack, tbl)

table.insert(output, "{\n")
for key, value in pairs(tbl) do
local innerIndent = (indent or " ") .. (indent or " ")
table.insert(output, innerIndent .. tostring(key) .. " = ")
table.insert(output,
table.insert(output,
value == tbl and "<self>," or table.tostring(value, innerIndent, limit, depth, jstack)
)

i = i + 1
if i > limit then
table.insert(output, (innerIndent or "") .. "...\n")
break
end
end

table.insert(output, indent and (indent or "") .. "},\n" or "}")
else
if type(tbl) == "string" then tbl = string.format("%q", tbl) end -- quote strings
if type(tbl) == "string" then tbl = string.format("%q", tbl) end -- quote strings
table.insert(output, tostring(tbl) .. ",\n")
end

return table.concat(output)
end
2 changes: 1 addition & 1 deletion lib/stdlib/helpers/autoload.lua
Expand Up @@ -2,7 +2,7 @@ function wax.autoload(...)
for i, folder in ipairs({...}) do
local files = wax.filesystem.search(wax.root(folder), "lua$")
for i, file in ipairs(files) do
local requireString = file:match(wax.root() .. "/(.*)%.lua$")
local requireString = file:match(wax.root() .. "/(.*)%.lua$")
requireString = requireString:gsub("/", ".")
require(requireString)
end
Expand Down

0 comments on commit 6c1e726

Please sign in to comment.