Comparing version 3.3.0 to 3.3.1
@@ -0,1 +1,5 @@ | ||
v3.3.1 (2017-03-27) | ||
------------------- | ||
[new] Added support for freezing objects | ||
v3.2.0 (2017-02-10) | ||
@@ -2,0 +6,0 @@ ------------------- |
@@ -31,4 +31,5 @@ const fs = require('fs'); | ||
const _freeze = function freeze(object) { | ||
if (typeof object === 'object' || object === 'function') { | ||
object = new Proxy(object, { | ||
if (typeof object === 'object' || typeof object === 'function') { | ||
return new Proxy(object, { | ||
get: (target, key) => _freeze(object[key]), | ||
set: (target, key) => { throw new Error('Object is read-only.') }, | ||
@@ -35,0 +36,0 @@ setPrototypeOf: (target, key) => { throw new Error('Object is read-only.') }, |
@@ -16,3 +16,3 @@ { | ||
], | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"main": "index.js", | ||
@@ -19,0 +19,0 @@ "repository": { |
@@ -743,8 +743,6 @@ const assert = require("assert"); | ||
let x = { | ||
a() { | ||
return 'a'; | ||
}, | ||
b() { | ||
return 'b' | ||
a: () => 'a', | ||
b: () => 'b', | ||
c: { | ||
d: () => 'd' | ||
} | ||
@@ -756,6 +754,7 @@ } | ||
}); | ||
vm.run('x.a = () => { return `-` }; (y) => { y.b = () => { return `--` } }')(x); | ||
vm.run('x.a = () => { return `-` }; x.c.d = () => { return `---` }; (y) => { y.b = () => { return `--` } }')(x); | ||
assert.strictEqual(x.a(), '-'); | ||
assert.strictEqual(x.b(), '--'); | ||
assert.strictEqual(x.c.d(), '---'); | ||
@@ -767,8 +766,6 @@ done() | ||
let x = VM.freeze({ | ||
a() { | ||
return 'a'; | ||
}, | ||
b() { | ||
return 'b' | ||
a: () => 'a', | ||
b: () => 'b', | ||
c: { | ||
d: () => 'd' | ||
} | ||
@@ -789,4 +786,8 @@ }); | ||
assert.throws(() => { | ||
vm.run('x.c.d = () => { return `---` };'); | ||
}, /Object is read-only\./); | ||
done() | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72797
1844