+1
-1
@@ -5,3 +5,3 @@ { | ||
| "description": "JavaScript Super Notation (JSON + circular refs + dates + (optional)functions)", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "keywords": [], | ||
@@ -8,0 +8,0 @@ "dependencies": { |
+10
-4
@@ -83,2 +83,5 @@ function type(val){ | ||
| function encodeObject(from, to, circular) { | ||
| if (from.constructor != Object) { | ||
| to['_jssn_proto'] = /^function([^\(]+)\(/.exec(from.constructor.toString())[1].trim(); | ||
| } | ||
| var k = keys(from); | ||
@@ -102,3 +105,3 @@ for (var i = 0; i < k.length; i++) { | ||
| function parse(str) { | ||
| function parse(str, constructors) { | ||
| var source = JSON.parse(str).map(function (o, i) { | ||
@@ -116,7 +119,10 @@ if (type(o) === 'array') { | ||
| decoded: false, | ||
| original: {} | ||
| original: o['_jssn_proto'] && constructors[o['_jssn_proto']] ? | ||
| Object.create(constructors[o['_jssn_proto']].prototype) | ||
| : {} | ||
| }; | ||
| } | ||
| if (type(o) === 'string' && i != 0) { | ||
| var parsed = /^function [^\(]*\(([^\)]*)\) \{(.*)\}$/.exec(o); | ||
| var parsed = /^function[^\(]*\(([^\)]*)\) ?\{((?:\n|\r|.)*)\}$/.exec(o); | ||
| if (!parsed) console.log(JSON.stringify(o)); | ||
| var args = parsed[1].split(',') | ||
@@ -126,3 +132,3 @@ .map(function (a) { return a.trim(); }) | ||
| args.push(parsed[2]); | ||
| return new Function(args); | ||
| return Function.apply(null, args); | ||
| } else { | ||
@@ -129,0 +135,0 @@ return {encoded: o, decoded: false, original: null}; |
+1
-1
| { | ||
| "name": "jssn", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "description": "JavaScript Super Notation (JSON + circular refs + dates + (optional)functions)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
5701
6.56%177
3.51%0
-100%