Skip to content

Commit

Permalink
Use Funciton Objects for deserailzation, instead of eval yahoo#158
Browse files Browse the repository at this point in the history
  • Loading branch information
tornikeshavishvili committed Jan 21, 2023
1 parent 7139f92 commit ff50bc5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ff50bc5

Please sign in to comment.