123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- --[[
- Copyright 2017 Stefano Mazzucco <stefano AT curso DOT re>
- This program is free software: you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or (at your option) any later
- version.
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
- You should have received a copy of the GNU General Public License along with
- this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
- ]]
- local helpers = {}
- function helpers.dir(obj, indent)
- indent = indent or ""
- if type(obj) == "table" then
- local out = "\n"
- for k, v in pairs(obj) do
- out = out ..
- indent ..
- helpers.dir(k) ..
- " :: " ..
- helpers.dir(v, indent .. " ") ..
- "\n"
- end
- return out
- else
- return indent .. tostring(obj)
- end
- end
- function helpers.concat_non_nil(values, sep)
- sep = sep or " "
- local text = ""
- for _, v in pairs(values) do
- text = text .. v .. sep
- end
- return text:sub(1, -2)
- end
- function helpers.reload(m)
- package.loaded[m] = nil
- return require(m)
- end
- return helpers
|