diff options
Diffstat (limited to 'util/serialization.lua')
-rw-r--r-- | util/serialization.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/util/serialization.lua b/util/serialization.lua index 04901135..206f5fbb 100644 --- a/util/serialization.lua +++ b/util/serialization.lua @@ -20,7 +20,7 @@ local debug_traceback = debug.traceback; local log = require "util.logger".init("serialization"); local envload = require"util.envload".envload; -module "serialization" +local _ENV = nil; local indent = function(i) return string_rep("\t", i); @@ -71,16 +71,16 @@ local function _simplesave(o, ind, t, func) end end -function append(t, o) +local function append(t, o) _simplesave(o, 1, t, t.write or t_insert); return t; end -function serialize(o) +local function serialize(o) return t_concat(append({}, o)); end -function deserialize(str) +local function deserialize(str) if type(str) ~= "string" then return nil; end str = "return "..str; local f, err = envload(str, "@data", {}); @@ -90,4 +90,8 @@ function deserialize(str) return ret; end -return _M; +return { + append = append; + serialize = serialize; + deserialize = deserialize; +}; |