Software /
code /
prosody
Diff
util/serialization.lua @ 6777:5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Feb 2015 10:36:37 +0100 |
parent | 6670:5e72f7aadbcc |
child | 8555:4f0f5b49bb03 |
line wrap: on
line diff
--- a/util/serialization.lua Mon Aug 10 22:16:05 2015 +0200 +++ b/util/serialization.lua Sat Feb 21 10:36:37 2015 +0100 @@ -20,7 +20,7 @@ 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 @@ 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 @@ return ret; end -return _M; +return { + append = append; + serialize = serialize; + deserialize = deserialize; +};