Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vm2

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vm2 - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

4

CHANGELOG.md

@@ -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 @@ -------------------

5

lib/main.js

@@ -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()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc