From ff50bc5bb07f1c766750bc7241b93606d0d7de16 Mon Sep 17 00:00:00 2001 From: tornikeshavishvili Date: Sat, 21 Jan 2023 15:45:03 +0400 Subject: [PATCH] Use Funciton Objects for deserailzation, instead of eval #158 --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ef54077..7d7f17d 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,11 @@ function deleteFunctions(obj){ } } -module.exports = function serialize(obj, options) { +module.exports.deserialize = function(objStr){ + return new Function("return " + objStr)(); +}; + +module.exports.serialize = function serialize(obj, options) { options || (options = {}); // Backwards-compatibility for `space` as the second argument.