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

immutable-assign

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-assign - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

3

deploy/iassign.d.ts

@@ -8,2 +8,5 @@

freezeOutput: boolean; // Deep freeze output
disableAllCheck: boolean;
disableHasReturnCheck: boolean;
disableExtraStatementCheck: boolean;
}

@@ -10,0 +13,0 @@

2

deploy/iassign.js

@@ -182,3 +182,3 @@ "use strict";

var otherBodyText = bodyText.substr(0, returnIndex).trim();
if (otherBodyText != "") {
if (otherBodyText != "" && otherBodyText != '"use strict";') {
throw new Error("getProp() function has statements other than 'return': " + otherBodyText);

@@ -185,0 +185,0 @@ }

@@ -61,5 +61,7 @@ // Karma configuration

// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// If our browser install to the default location, we need to set the environment variable point to the installation path.
// E.g., SET FIREFOX_BIN="C:\Program Files (x86)\MozillaFirefox4x\firefox.exe"
// Refer to http://karma-runner.github.io/1.0/config/browsers.html
browsers: ["Chrome", "Firefox", "IE", "PhantomJS" ],
// Continuous Integration mode

@@ -66,0 +68,0 @@ // if true, Karma captures browsers, runs the tests and exits

{
"name": "immutable-assign",
"version": "1.0.15",
"version": "1.0.16",
"description": "",

@@ -42,3 +42,6 @@ "main": "src/iassign.js",

"karma-chrome-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.1",
"lodash": "^4.13.1",

@@ -45,0 +48,0 @@ "merge2": "^1.0.2",

@@ -197,4 +197,6 @@ # immutable-assign (iassign.js)

##History
* 1.0.16 - Tested in Node.js and major browsers (IE 11, Chrome 52, Firefox 47, PhantomJS 2)

@@ -11,3 +11,3 @@ "use strict";

// Browser globals (root is window)
let require = (name) => {
var require = function(name) {
if (name == "deep-freeze" && root.deepFreeze) {

@@ -36,4 +36,16 @@ return root.deepFreeze;

// Uncomment following line to test code coverage: npm run cover
// iassign.disableExtraStatementCheck = true;
if (typeof(global) !== "undefined") {
console.log("In node");
if (global.process.env.running_under_istanbul) {
// Handle coverage tool that may modify the source code.
iassign.disableExtraStatementCheck = true;
}
}
if (typeof(window) !== "undefined") {
console.log("In browser");
if (window.__coverage__) {
iassign.disableExtraStatementCheck = true;
}
}

@@ -300,3 +312,3 @@ describe("Test 2", function () {

expect(() => {
expect(function () {
var o2 = iassign(o1, function (o) {

@@ -312,3 +324,3 @@ return o.a.b.c[0]["["]

expect(() => {
expect(function () {
var o2 = iassign(o1, function (o) {

@@ -327,3 +339,3 @@ return o.a.b.c[0]["]"]

expect(() => {
expect(function () {
var o2 = iassign(o1, function (o) {

@@ -335,5 +347,6 @@ o.a.b.c[0][0]

it("getProp() function has other statements should throw exception", function () {
if (iassign.disableExtraStatementCheck)
it("getProp() function has other statements should throw exception", function () {
if (iassign.disableExtraStatementCheck) {
return;
}

@@ -343,3 +356,3 @@ var o1 = { a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]] } } };

expect(() => {
expect(function () {
var o2 = iassign(o1, function (o) {

@@ -350,2 +363,53 @@ var text = "unexpected text";

}).toThrowError(/has statements other than 'return'/);
});
it("getProp() disableExtraStatementCheck", function () {
var o1 = { a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]], c2: {} }, b2: {} }, a2: {} };
deepFreeze(o1);
var o2 = iassign(
o1,
function (o) {
var text = "unexpected text";
return o.a.b.c[0][0];
},
function (ci) { ci.d++; return ci; },
undefined,
{
disableExtraStatementCheck: true
}
);
//
// Jasmine Tests
//
// expect o1 has not been changed
expect(o1).toEqual({ a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]], c2: {} }, b2: {} }, a2: {} })
// expect o2 inner property has been updated.
expect(o2.a.b.c[0][0].d).toBe(12);
// expect object graph for changed property in o2 is now different from (!==) o1.
expect(o2).not.toBe(o1);
expect(o2.a).not.toBe(o1.a);
expect(o2.a.b).not.toBe(o1.a.b);
expect(o2.a.b.c).not.toBe(o1.a.b.c);
expect(o2.a.b.c[0]).not.toBe(o1.a.b.c[0]);
expect(o2.a.b.c[0][0]).not.toBe(o1.a.b.c[0][0]);
expect(o2.a.b.c[0][0].d).not.toBe(o1.a.b.c[0][0].d);
// expect object graph for unchanged property in o2 is still equal to (===) o1.
expect(o2.a2).toBe(o1.a2);
expect(o2.a.b2).toBe(o1.a.b2);
expect(o2.a.b.c2).toBe(o1.a.b.c2);
expect(o2.a.b.c[0][0].e).toBe(o1.a.b.c[0][0].e);
expect(o2.a.b.c[1][0]).toBe(o1.a.b.c[1][0]);
expect(o2.a.b.c[2][0]).toBe(o1.a.b.c[2][0]);
// var o2 = iassign(o1, function (o) {
// var text = "unexpected text";
// return o.a.b.c[0][0];
// }, function (ci) { ci.d++; return ci; });
});

@@ -352,0 +416,0 @@

@@ -238,12 +238,12 @@ "use strict";

iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].push(3); return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /Can't|writable|doesn't|support|readonly/i);
expect(function () {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { ci[0].d++; return ci; });
}).toThrowError(TypeError, /Cannot assign to read only property/);
}).toThrowError(TypeError, /Cannot|read only|read-only|extensible|readonly/i);
expect(function () {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { ci[0].g = 1; return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /add|extensible|readonly/i);
expect(function () {
iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].pop(); return ci; });
}).toThrowError(TypeError, /object is not extensible|Cannot delete property/);
}).toThrowError(TypeError, /extensible|Cannot|can't|support|unable/i);
});

@@ -364,12 +364,12 @@ it("Update array using lodash", function () {

iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].push(3); return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /Can't|writable|doesn't|support|readonly/i);
expect(function () {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { ci[0].d++; return ci; });
}).toThrowError(TypeError, /Cannot assign to read only property/);
}).toThrowError(TypeError, /Cannot|read only|read-only|extensible|readonly/i);
expect(function () {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { ci[0].g = 1; return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /add|extensible|readonly/i);
expect(function () {
iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].pop(); return ci; });
}).toThrowError(TypeError, /object is not extensible|Cannot delete property/);
}).toThrowError(TypeError, /extensible|Cannot|can't|support|unable/i);
iassign.freezeInput = undefined;

@@ -398,12 +398,12 @@ });

o2.a.b.c[0].push(3);
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /Can't|writable|doesn't|support|readonly/i);
expect(function () {
o2.a.b.c[0][0].d++;
}).toThrowError(TypeError, /Cannot assign to read only property/);
}).toThrowError(TypeError, /Cannot|read only|read-only|extensible|readonly/i);
expect(function () {
o2.a.b.c[0][0].g = 1;
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /add|extensible|readonly/i);
expect(function () {
o2.a.b.c[0].pop();
}).toThrowError(TypeError, /object is not extensible|Cannot delete property/);
}).toThrowError(TypeError, /extensible|Cannot|can't|support|unable/i);
iassign.freezeOutput = undefined;

@@ -410,0 +410,0 @@ });

@@ -297,15 +297,15 @@

iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].push(<any>3); return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /Can't|writable|doesn't|support|readonly/i);
expect(() => {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { ci[0].d++; return ci; });
}).toThrowError(TypeError, /Cannot assign to read only property/);
}).toThrowError(TypeError, /Cannot|read only|read-only|extensible|readonly/i);
expect(() => {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { (<any>ci[0]).g = 1; return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /add|extensible|readonly/i);
expect(() => {
iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].pop(); return ci; });
}).toThrowError(TypeError, /object is not extensible|Cannot delete property/);
}).toThrowError(TypeError, /extensible|Cannot|can't|support|unable/i);
});

@@ -481,15 +481,15 @@

iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].push(<any>3); return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /Can't|writable|doesn't|support|readonly/i);
expect(() => {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { ci[0].d++; return ci; });
}).toThrowError(TypeError, /Cannot assign to read only property/);
}).toThrowError(TypeError, /Cannot|read only|read-only|extensible|readonly/i);
expect(() => {
iassign(o1, function (o) { return o.a.b.c[0]; }, function (ci) { (<any>ci[0]).g = 1; return ci; });
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /add|extensible|readonly/i);
expect(() => {
iassign(o1, function (o) { return o.a.b.c; }, function (ci) { ci[0].pop(); return ci; });
}).toThrowError(TypeError, /object is not extensible|Cannot delete property/);
}).toThrowError(TypeError, /extensible|Cannot|can't|support|unable/i);

@@ -528,15 +528,15 @@ iassign.freezeInput = undefined;

o2.a.b.c[0].push(<any>3);
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /Can't|writable|doesn't|support|readonly/i);
expect(() => {
o2.a.b.c[0][0].d++;
}).toThrowError(TypeError, /Cannot assign to read only property/);
}).toThrowError(TypeError, /Cannot|read only|read-only|extensible|readonly/i);
expect(() => {
(<any>o2.a.b.c[0][0]).g = 1;
}).toThrowError(TypeError, /Can't add property/);
}).toThrowError(TypeError, /add|extensible|readonly/i);
expect(() => {
o2.a.b.c[0].pop();
}).toThrowError(TypeError, /object is not extensible|Cannot delete property/);
}).toThrowError(TypeError, /extensible|Cannot|can't|support|unable/i);

@@ -543,0 +543,0 @@ iassign.freezeOutput = undefined;

@@ -8,2 +8,5 @@

freezeOutput: boolean; // Deep freeze output
disableAllCheck: boolean;
disableHasReturnCheck: boolean;
disableExtraStatementCheck: boolean;
}

@@ -10,0 +13,0 @@

@@ -182,3 +182,3 @@ "use strict";

var otherBodyText = bodyText.substr(0, returnIndex).trim();
if (otherBodyText != "") {
if (otherBodyText != "" && otherBodyText != '"use strict";') {
throw new Error("getProp() function has statements other than 'return': " + otherBodyText);

@@ -185,0 +185,0 @@ }

@@ -240,3 +240,3 @@ "use strict"

let otherBodyText = bodyText.substr(0, returnIndex).trim();
if (otherBodyText != "") {
if (otherBodyText != "" && otherBodyText != '"use strict";') {
throw new Error("getProp() function has statements other than 'return': " + otherBodyText);

@@ -243,0 +243,0 @@ }

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