From d25cac3be42001915f3d872fb68e6b71c2657c9f Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sat, 4 Dec 2021 22:21:28 +1100 Subject: [PATCH] Revert "feat(init): add custom packing for metatables" This reverts commit 1ad137b8c59b03f532122c0ab8c215ec5222d6e5. Prefer native solutions, this is too niche. --- README.md | 2 -- init.lua | 26 ++------------------------ 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index ea9b987..6b94ee4 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,7 @@ Any resources distributed with this code is subject to the same license restrict #### Currently implemented - [x] Server callbacks - [x] Table utilities -- [x] OxMySQL wrapper (might scrap for oxmysql v2.0.0) - [x] Streaming exports -- [x] Metatable packing/unpacking - [x] SetInterval #### To do diff --git a/init.lua b/init.lua index 90e0e2f..dc39f30 100644 --- a/init.lua +++ b/init.lua @@ -46,8 +46,8 @@ local function loadFile(self, file) else error(('\n^3Unable to import module (%s)^0'):format(dir), 3) end end ----Loads a module from the library. ----If the module has already been loaded then it will reference the existing chunk. +--- Loads a module from the library. +--- If the module has already been loaded then it will reference the existing chunk. ---@param file string ---@return table local function getImport(self, file) @@ -71,30 +71,8 @@ import = setmetatable({}, { }) local lib = {} -local msgpack_new = msgpack.new -local msgpack_unpack = msgpack.unpack -local getmetatable = getmetatable local setmetatable = setmetatable ----@param tbl table ---- packs a table and metatable with msgpack -function lib.pack(tbl) - local userdata = msgpack_new() - userdata:_table(tbl) - - local mt = getmetatable(tbl) - if mt then userdata:table(mt) end - - return tostring(userdata), not mt and true -end - ----@param data string ---- unpacks a msgpack table and metatable -function lib.unpack(data) - local tbl, mt = msgpack_unpack(data) - return mt and setmetatable(tbl, mt) or tbl -end - setmetatable(lib, { __index = exports[LIBRARY],