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

seamless-immutable

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seamless-immutable - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

4

package.json
{
"name": "seamless-immutable",
"version": "4.1.0",
"version": "4.1.1",
"description": "Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.",
"main": "src/seamless-immutable.js",
"devDependencies": {
"chai": "3.2.0",
"chai": "3.4.1",
"coveralls": "2.11.2",

@@ -9,0 +9,0 @@ "envify": "3.4.0",

@@ -231,2 +231,6 @@ seamless-immutable

#### 4.1.1
Make `setIn` more null safe.
#### 4.1.0

@@ -233,0 +237,0 @@

@@ -101,2 +101,4 @@ (function(){

var immutableEmptyArray = Immutable([]);
function arraySetIn(pth, value) {

@@ -109,6 +111,13 @@ var head = pth[0];

var tail = pth.slice(1);
// this[head] might (validly) be an (immutable) array or object
var newValue = this[head].setIn(tail, value);
var thisHead = this[head];
var newValue;
if (head in this && this[head] === newValue) {
if (typeof(thisHead) === "object" && thisHead !== null && typeof(thisHead.setIn) === "function") {
// Might (validly) be object or array
newValue = thisHead.setIn(tail, value);
} else {
newValue = arraySetIn.call(immutableEmptyArray, tail, value);
}
if (head in this && thisHead === newValue) {
return this;

@@ -369,5 +378,7 @@ }

var newValue;
if (this.hasOwnProperty(head) && this[head] !== undefined) {
var thisHead = this[head];
if (this.hasOwnProperty(head) && typeof(thisHead) === "object" && thisHead !== null && typeof(thisHead.setIn) === "function") {
// Might (validly) be object or array
newValue = this[head].setIn(tail, value);
newValue = thisHead.setIn(tail, value);
} else {

@@ -377,3 +388,3 @@ newValue = objectSetIn.call(immutableEmptyObject, tail, value);

if (this.hasOwnProperty(head) && this[head] === newValue) {
if (this.hasOwnProperty(head) && thisHead === newValue) {
return this;

@@ -380,0 +391,0 @@ }

@@ -1,1 +0,1 @@

!function(){"use strict";function a(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function b(b){a(b,x,!0)}function c(a){return"object"==typeof a?null===a||a.hasOwnProperty(x):!0}function d(a){return!(null===a||"object"!=typeof a||a instanceof Array||a instanceof Date)}function e(a){var b=new Error(a);return b.__proto__=e,b}function f(a,c){b(a);return a}function g(b,c){var d=b[c];a(b,c,function(){return w(d.apply(b,arguments))})}function h(a,b){if(a in this&&this[a]===b)return this;var c=m.call(this);return c[a]=w(b),j(c)}function i(a,b){var c=a[0];if(1===a.length)return h.call(this,c,b);var d=a.slice(1),e=this[c].setIn(d,b);if(c in this&&this[c]===e)return this;var f=m.call(this);return f[c]=e,j(f)}function j(b){for(var c in B)if(B.hasOwnProperty(c)){var d=B[c];g(b,d)}a(b,"flatMap",k),a(b,"asObject",n),a(b,"asMutable",m),a(b,"set",h),a(b,"setIn",i);for(var e=0,j=b.length;j>e;e++)b[e]=w(b[e]);return f(b,A)}function k(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function l(a){if(0===arguments.length)return this;a instanceof Array||(a=Array.prototype.slice.call(arguments));var b=this.instantiateEmptyObject();for(var c in this)this.hasOwnProperty(c)&&-1===a.indexOf(c)&&(b[c]=this[c]);return v(b,{instantiateEmptyObject:this.instantiateEmptyObject})}function m(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(o(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function n(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return v(c)}function o(a){return!a||!a.hasOwnProperty(x)||a instanceof Date?a:a.asMutable({deep:!0})}function p(a,b){for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function q(a,b){function c(a,c,f){var g=w(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=p(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;j<a.length;j++){var k=a[j];for(f in k)k.hasOwnProperty(f)&&c(this,k,f)}else for(f in a)a.hasOwnProperty(f)&&c(this,a,f);return void 0===e?this:v(e,{instantiateEmptyObject:this.instantiateEmptyObject})}function r(a,b){var c=a[0];if(1===a.length)return s.call(this,c,b);var d,e=a.slice(1);if(d=this.hasOwnProperty(c)&&void 0!==this[c]?this[c].setIn(e,b):r.call(C,e,b),this.hasOwnProperty(c)&&this[c]===d)return this;var f=p(this,this.instantiateEmptyObject());return f[c]=d,v(f,this)}function s(a,b){if(this.hasOwnProperty(a)&&this[a]===b)return this;var c=p(this,this.instantiateEmptyObject());return c[a]=w(b),v(c,this)}function t(a){var b,c=this.instantiateEmptyObject();if(a&&a.deep)for(b in this)this.hasOwnProperty(b)&&(c[b]=o(this[b]));else for(b in this)this.hasOwnProperty(b)&&(c[b]=this[b]);return c}function u(){return{}}function v(b,c){var d=c&&c.instantiateEmptyObject?c.instantiateEmptyObject:u;return a(b,"merge",q),a(b,"without",l),a(b,"asMutable",t),a(b,"instantiateEmptyObject",d),a(b,"set",s),a(b,"setIn",r),f(b,y)}function w(a,b){if(c(a))return a;if(a instanceof Array)return j(a.slice());if(a instanceof Date)return f(new Date(a.getTime()));var d=b&&b.prototype,e=d&&d!==Object.prototype?function(){return Object.create(d)}:u,g=e();for(var h in a)a.hasOwnProperty(h)&&(g[h]=w(a[h]));return v(g,{instantiateEmptyObject:e})}var x="__immutable_invariants_hold",y=["setPrototypeOf"],z=["keys"],A=y.concat(["push","pop","sort","splice","shift","unshift","reverse"]),B=z.concat(["map","filter","slice","concat","reduce","reduceRight"]);e.prototype=Error.prototype;var C=w({});w.isImmutable=c,w.ImmutableError=e,Object.freeze(w),"object"==typeof module?module.exports=w:"object"==typeof exports?exports.Immutable=w:"object"==typeof window?window.Immutable=w:"object"==typeof global&&(global.Immutable=w)}();
!function(){"use strict";function a(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function b(b){a(b,x,!0)}function c(a){return"object"==typeof a?null===a||a.hasOwnProperty(x):!0}function d(a){return!(null===a||"object"!=typeof a||a instanceof Array||a instanceof Date)}function e(a){var b=new Error(a);return b.__proto__=e,b}function f(a,c){b(a);return a}function g(b,c){var d=b[c];a(b,c,function(){return w(d.apply(b,arguments))})}function h(a,b){if(a in this&&this[a]===b)return this;var c=m.call(this);return c[a]=w(b),j(c)}function i(a,b){var c=a[0];if(1===a.length)return h.call(this,c,b);var d,e=a.slice(1),f=this[c];if(d="object"==typeof f&&null!==f&&"function"==typeof f.setIn?f.setIn(e,b):i.call(C,e,b),c in this&&f===d)return this;var g=m.call(this);return g[c]=d,j(g)}function j(b){for(var c in B)if(B.hasOwnProperty(c)){var d=B[c];g(b,d)}a(b,"flatMap",k),a(b,"asObject",n),a(b,"asMutable",m),a(b,"set",h),a(b,"setIn",i);for(var e=0,j=b.length;j>e;e++)b[e]=w(b[e]);return f(b,A)}function k(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function l(a){if(0===arguments.length)return this;a instanceof Array||(a=Array.prototype.slice.call(arguments));var b=this.instantiateEmptyObject();for(var c in this)this.hasOwnProperty(c)&&-1===a.indexOf(c)&&(b[c]=this[c]);return v(b,{instantiateEmptyObject:this.instantiateEmptyObject})}function m(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(o(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function n(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return v(c)}function o(a){return!a||!a.hasOwnProperty(x)||a instanceof Date?a:a.asMutable({deep:!0})}function p(a,b){for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function q(a,b){function c(a,c,f){var g=w(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=p(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;j<a.length;j++){var k=a[j];for(f in k)k.hasOwnProperty(f)&&c(this,k,f)}else for(f in a)a.hasOwnProperty(f)&&c(this,a,f);return void 0===e?this:v(e,{instantiateEmptyObject:this.instantiateEmptyObject})}function r(a,b){var c=a[0];if(1===a.length)return s.call(this,c,b);var d,e=a.slice(1),f=this[c];if(d=this.hasOwnProperty(c)&&"object"==typeof f&&null!==f&&"function"==typeof f.setIn?f.setIn(e,b):r.call(D,e,b),this.hasOwnProperty(c)&&f===d)return this;var g=p(this,this.instantiateEmptyObject());return g[c]=d,v(g,this)}function s(a,b){if(this.hasOwnProperty(a)&&this[a]===b)return this;var c=p(this,this.instantiateEmptyObject());return c[a]=w(b),v(c,this)}function t(a){var b,c=this.instantiateEmptyObject();if(a&&a.deep)for(b in this)this.hasOwnProperty(b)&&(c[b]=o(this[b]));else for(b in this)this.hasOwnProperty(b)&&(c[b]=this[b]);return c}function u(){return{}}function v(b,c){var d=c&&c.instantiateEmptyObject?c.instantiateEmptyObject:u;return a(b,"merge",q),a(b,"without",l),a(b,"asMutable",t),a(b,"instantiateEmptyObject",d),a(b,"set",s),a(b,"setIn",r),f(b,y)}function w(a,b){if(c(a))return a;if(a instanceof Array)return j(a.slice());if(a instanceof Date)return f(new Date(a.getTime()));var d=b&&b.prototype,e=d&&d!==Object.prototype?function(){return Object.create(d)}:u,g=e();for(var h in a)a.hasOwnProperty(h)&&(g[h]=w(a[h]));return v(g,{instantiateEmptyObject:e})}var x="__immutable_invariants_hold",y=["setPrototypeOf"],z=["keys"],A=y.concat(["push","pop","sort","splice","shift","unshift","reverse"]),B=z.concat(["map","filter","slice","concat","reduce","reduceRight"]);e.prototype=Error.prototype;var C=w([]),D=w({});w.isImmutable=c,w.ImmutableError=e,Object.freeze(w),"object"==typeof module?module.exports=w:"object"==typeof exports?exports.Immutable=w:"object"==typeof window?window.Immutable=w:"object"==typeof global&&(global.Immutable=w)}();

@@ -101,2 +101,4 @@ (function(){

var immutableEmptyArray = Immutable([]);
function arraySetIn(pth, value) {

@@ -109,6 +111,13 @@ var head = pth[0];

var tail = pth.slice(1);
// this[head] might (validly) be an (immutable) array or object
var newValue = this[head].setIn(tail, value);
var thisHead = this[head];
var newValue;
if (head in this && this[head] === newValue) {
if (typeof(thisHead) === "object" && thisHead !== null && typeof(thisHead.setIn) === "function") {
// Might (validly) be object or array
newValue = thisHead.setIn(tail, value);
} else {
newValue = arraySetIn.call(immutableEmptyArray, tail, value);
}
if (head in this && thisHead === newValue) {
return this;

@@ -369,5 +378,7 @@ }

var newValue;
if (this.hasOwnProperty(head) && this[head] !== undefined) {
var thisHead = this[head];
if (this.hasOwnProperty(head) && typeof(thisHead) === "object" && thisHead !== null && typeof(thisHead.setIn) === "function") {
// Might (validly) be object or array
newValue = this[head].setIn(tail, value);
newValue = thisHead.setIn(tail, value);
} else {

@@ -377,3 +388,3 @@ newValue = objectSetIn.call(immutableEmptyObject, tail, value);

if (this.hasOwnProperty(head) && this[head] === newValue) {
if (this.hasOwnProperty(head) && thisHead === newValue) {
return this;

@@ -380,0 +391,0 @@ }

@@ -17,3 +17,3 @@ var JSC = require("jscheck");

describe("Immutable", function () {
it("makes an Immutable Array when passed a mutable array", function () {

@@ -23,3 +23,3 @@ TestUtils.check(100, [JSC.array()], function (mutable) {

assert.deepEqual(immutable, mutable);
TestUtils.assertJsonEqual(immutable, mutable);
assert.isTrue(Immutable.isImmutable(immutable));

@@ -45,3 +45,3 @@ assert.isFalse(Immutable.isImmutable(mutable));

assert.deepEqual(immutable, mutable);
TestUtils.assertJsonEqual(immutable, mutable);
assert.isTrue(Immutable.isImmutable(immutable));

@@ -57,3 +57,3 @@ assert.isTrue(Immutable.isImmutable(immutable[1]))

});
it("returns an object with the given optional prototype", function() {

@@ -65,6 +65,6 @@ function TestClass(o) { _.extend(this, o); };

assert.deepEqual(immutable, data);
TestUtils.assertJsonEqual(immutable, data);
TestUtils.assertHasPrototype(immutable, TestClass.prototype);
});
// These are already immutable, and should pass through Immutable() untouched.

@@ -71,0 +71,0 @@ _.each({

@@ -19,3 +19,3 @@ var JSC = require("jscheck");

assert.isFalse( Immutable.isImmutable(mutable));
assert.deepEqual(immutable,mutable);
TestUtils.assertJsonEqual(immutable,mutable);
});

@@ -33,3 +33,3 @@

TestUtils.assertIsDeeplyImmutable(mutable[0].deep);
assert.deepEqual(immutable,mutable);
TestUtils.assertJsonEqual(immutable,mutable);
});

@@ -49,3 +49,3 @@

assert.isFalse( Immutable.isImmutable(mutable[0]['deep']));
assert.deepEqual(immutable,mutable);
TestUtils.assertJsonEqual(immutable,mutable);
});

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

@@ -24,3 +24,3 @@ var JSC = require("jscheck");

// Check that the index argument we receive works as expected.
assert.deepEqual(value, array[index], "Expected array[" + index + "] to be " + value);
TestUtils.assertJsonEqual(value, array[index], "Expected array[" + index + "] to be " + value);

@@ -30,3 +30,3 @@ return [keys[index], values[index]]

assert.deepEqual(result, obj);
TestUtils.assertJsonEqual(result, obj);
});

@@ -43,3 +43,3 @@ });

assert.deepEqual(result, obj);
TestUtils.assertJsonEqual(result, obj);
});

@@ -55,5 +55,5 @@ });

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});
});
};

@@ -31,3 +31,3 @@ var JSC = require("jscheck");

assert.typeOf(index, "number");
assert.deepEqual(immutable[index], mutable[index]);
TestUtils.assertJsonEqual(immutable[index], mutable[index]);
}, [JSC.integer()]);

@@ -39,3 +39,3 @@ });

for (var index=0; index < immutable.length; index++) {
assert.deepEqual(immutable[index], mutable[index]);
TestUtils.assertJsonEqual(immutable[index], mutable[index]);
}

@@ -48,3 +48,3 @@ });

for (var index in immutable) {
assert.deepEqual(immutable[index], mutable[index]);
TestUtils.assertJsonEqual(immutable[index], mutable[index]);
}

@@ -56,3 +56,3 @@ });

checkImmutableMutable(function(immutable, mutable, otherArray) {
assert.deepEqual(immutable.concat(otherArray), mutable.concat(otherArray));
TestUtils.assertJsonEqual(immutable.concat(otherArray), mutable.concat(otherArray));
}, [JSC.array()]);

@@ -63,3 +63,3 @@ });

checkImmutableMutable(function(immutable, mutable, otherArray) {
assert.deepEqual(otherArray.concat(immutable), otherArray.concat(mutable));
TestUtils.assertJsonEqual(otherArray.concat(immutable), otherArray.concat(mutable));
}, [JSC.array()]);

@@ -70,3 +70,3 @@ });

checkImmutableMutable(function(immutable, mutable) {
assert.deepEqual(immutable.concat(immutable), mutable.concat(mutable));
TestUtils.assertJsonEqual(immutable.concat(immutable), mutable.concat(mutable));
});

@@ -83,3 +83,3 @@ });

checkImmutableMutable(function(immutable, mutable) {
assert.deepEqual(JSON.stringify(immutable), JSON.stringify(mutable));
TestUtils.assertJsonEqual(JSON.stringify(immutable), JSON.stringify(mutable));
});

@@ -117,3 +117,3 @@ });

assert.strictEqual(immutable.length, mutable.length);
assert.deepEqual(immutable[randomIndex], mutable[randomIndex]);
TestUtils.assertJsonEqual(immutable[randomIndex], mutable[randomIndex]);
}, [JSC.integer(), JSC.any()]);

@@ -130,3 +130,3 @@ });

immutableArr.sort();
assert.deepEqual(immutableArr, [2, 3, 4]);
TestUtils.assertJsonEqual(immutableArr, [2, 3, 4]);
});

@@ -166,3 +166,3 @@ }

for (var index in copiedArray) {
assert.deepEqual(immutable[index], copiedArray[index]);
TestUtils.assertJsonEqual(immutable[index], copiedArray[index]);
}

@@ -169,0 +169,0 @@ }, [JSC.array(), JSC.object()]);

@@ -19,3 +19,3 @@ var JSC = require("jscheck");

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -30,3 +30,3 @@

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -41,3 +41,3 @@ });

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -53,3 +53,3 @@ });

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -63,3 +63,3 @@ });

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -75,3 +75,3 @@ });

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

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

@@ -30,3 +30,3 @@ var JSC = require("jscheck");

assert.deepEqual(immutable, mutable);
TestUtils.assertJsonEqual(immutable, mutable);
});

@@ -51,3 +51,3 @@ });

var mutable = immutable.asMutable();
assert.deepEqual(immutable, mutable);
TestUtils.assertJsonEqual(immutable, mutable);
if (Immutable.isImmutable(mutable[idx])) {

@@ -58,3 +58,3 @@ mutable[idx] = mutable[idx].asMutable();

assert.deepEqual(
TestUtils.assertJsonEqual(
immutable.setIn([idx, key], value),

@@ -61,0 +61,0 @@ mutable

@@ -19,3 +19,3 @@ var JSC = require("jscheck");

assert.isFalse( Immutable.isImmutable(mutable));
assert.deepEqual(immutable,mutable);
TestUtils.assertJsonEqual(immutable,mutable);
assert.equal(Object.keys(mutable).length, 0);

@@ -34,3 +34,3 @@ });

TestUtils.assertIsDeeplyImmutable(mutable.deep.complex);
assert.deepEqual(immutable,mutable);
TestUtils.assertJsonEqual(immutable,mutable);
})

@@ -49,3 +49,3 @@ })

assert.isFalse(Immutable.isImmutable(mutable['deep']['complex']));
assert.deepEqual(immutable,mutable);
TestUtils.assertJsonEqual(immutable,mutable);
});

@@ -68,3 +68,3 @@ });

assert.deepEqual(result, data);
TestUtils.assertJsonEqual(result, data);
TestUtils.assertHasPrototype(result, TestClass.prototype);

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

@@ -32,3 +32,3 @@ var JSC = require("jscheck");

assert.deepEqual(immutableKeys, mutableKeys);
TestUtils.assertJsonEqual(immutableKeys, mutableKeys);
});

@@ -40,3 +40,3 @@ });

assert.typeOf(index, "number");
assert.deepEqual(immutable[index], mutable[index]);
TestUtils.assertJsonEqual(immutable[index], mutable[index]);
}, [JSC.integer()]);

@@ -48,3 +48,3 @@ });

for (var index=0; index < immutable.length; index++) {
assert.deepEqual(immutable[index], mutable[index]);
TestUtils.assertJsonEqual(immutable[index], mutable[index]);
}

@@ -57,3 +57,3 @@ });

for (var index in immutable) {
assert.deepEqual(immutable[index], mutable[index]);
TestUtils.assertJsonEqual(immutable[index], mutable[index]);
}

@@ -80,3 +80,3 @@ });

var immutable = Immutable(mutable);
assert.deepEqual(JSON.stringify(immutable), JSON.stringify(mutable));
TestUtils.assertJsonEqual(JSON.stringify(immutable), JSON.stringify(mutable));
});

@@ -114,3 +114,3 @@ });

assert.strictEqual(immutable.length, mutable.length);
assert.deepEqual(immutable[randomIndex], mutable[randomIndex]);
TestUtils.assertJsonEqual(immutable[randomIndex], mutable[randomIndex]);
}, [JSC.integer(), JSC.any()]);

@@ -151,3 +151,3 @@ });

});
it("supports handling dates without using prototype option", function() {

@@ -159,3 +159,3 @@ var date = new Date();

});
it("makes nested content immutable as well", function() {

@@ -192,3 +192,3 @@ checkImmutableMutable(function(immutable, mutable, innerArray, obj) {

for (var index in copiedArray) {
assert.deepEqual(immutable[index], copiedArray[index]);
TestUtils.assertJsonEqual(immutable[index], copiedArray[index]);
}

@@ -195,0 +195,0 @@ }, [JSC.array(), JSC.object()]);

@@ -15,3 +15,3 @@ var assert = require("chai").assert;

assert.isFalse(Immutable.isImmutable(obj));
assert.deepEqual(obj, {});
TestUtils.assertJsonEqual(obj, {});
});

@@ -21,3 +21,3 @@

function TestClass(o) { _.extend(this, o); };
var immutable = Immutable(new TestClass({a: 1, b: 2}),
var immutable = Immutable(new TestClass({a: 1, b: 2}),
{prototype: TestClass.prototype});

@@ -27,7 +27,7 @@

assert.isFalse(Immutable.isImmutable(obj));
assert.deepEqual(obj, {});
TestUtils.assertHasPrototype(obj, TestClass.prototype);
TestUtils.assertJsonEqual(obj, {});
TestUtils.assertHasPrototype(obj, TestClass.prototype);
});
});
};

@@ -167,3 +167,3 @@ var JSC = require("jscheck");

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -183,3 +183,3 @@

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -208,3 +208,3 @@ });

assert.deepEqual(actualShallow, expectedShallow);
TestUtils.assertJsonEqual(actualShallow, expectedShallow);

@@ -214,3 +214,3 @@ var expectedDeep = Immutable({all: "your base", are: {belong: "to us", you: {have: "no chance to survive", make: "your time"}}});

assert.deepEqual(actualDeep, expectedDeep);
TestUtils.assertJsonEqual(actualDeep, expectedDeep);
});

@@ -225,3 +225,3 @@

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -239,3 +239,3 @@

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -250,3 +250,3 @@

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -277,3 +277,3 @@

assert.deepEqual(result, _.extend({}, data, mergeData));
TestUtils.assertJsonEqual(result, _.extend({}, data, mergeData));
TestUtils.assertHasPrototype(result, TestClass.prototype);

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

@@ -27,3 +27,3 @@ var JSC = require("jscheck");

assert.deepEqual(
TestUtils.assertJsonEqual(
immutable.set(prop, value),

@@ -43,3 +43,3 @@ _.set(mutable, prop, value)

assert.deepEqual(immutable, mutable);
TestUtils.assertJsonEqual(immutable, mutable);

@@ -51,3 +51,3 @@ var path = [], depth = JSC.integer(1, 5)();

assert.deepEqual(
TestUtils.assertJsonEqual(
immutable.setIn(path, value),

@@ -54,0 +54,0 @@ _.set(mutable, path, value)

@@ -53,7 +53,7 @@ var JSC = require("jscheck");

assert.deepEqual(_.keys(result), expectedKeys);
TestUtils.assertJsonEqual(_.keys(result), expectedKeys);
// Make sure the remaining keys still point to the same values
_.each(_.keys(result), function(key) {
assert.deepEqual(immutable[key], result[key]);;
TestUtils.assertJsonEqual(immutable[key], result[key]);;
});

@@ -79,3 +79,3 @@ });

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});

@@ -88,6 +88,6 @@

assert.deepEqual(actual, expected);
TestUtils.assertJsonEqual(actual, expected);
});
});
it("preserves prototypes after call to without", function() {

@@ -100,3 +100,3 @@ function TestClass(o) { _.extend(this, o); };

assert.deepEqual(result, _.omit(data, 'b'));
TestUtils.assertJsonEqual(result, _.omit(data, 'b'));
TestUtils.assertHasPrototype(result, TestClass.prototype);

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

@@ -5,2 +5,13 @@ var JSC = require("jscheck");

function assertJsonEqual(first, second) {
if (typeof first === "object" && typeof second === "object" && first !== null && second !== null) {
assert.deepEqual(_.keys(first).sort(), _.keys(second).sort());
_.each(first, function(key, value) {
assertJsonEqual(first[key], second[key]);
});
} else {
assert.strictEqual(JSON.stringify(first), JSON.stringify(second));
}
}
function wrapAssertImmutable(Immutable) {

@@ -11,3 +22,3 @@ return function assertImmutable(methodName, immutableArray, mutableArray, args) {

assert.deepEqual(immutableResult, mutableResult);
assertJsonEqual(immutableResult, mutableResult);
}

@@ -119,2 +130,3 @@ }

return {
assertJsonEqual: assertJsonEqual,
assertImmutable: wrapAssertImmutable(Immutable),

@@ -121,0 +133,0 @@ assertIsDeeplyImmutable: wrapAssertIsDeeplyImmutable(Immutable),

Sorry, the diff of this file is not supported yet

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