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

immutable-class

Package Overview
Dependencies
Maintainers
3
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-class - npm Package Compare versions

Comparing version 0.9.6 to 0.9.7

build/test-utils/car.mock.d.ts

18

build/base-immutable/base-immutable.mocha.js

@@ -54,20 +54,2 @@ "use strict";

});
describe('getDifference', function () {
var car0 = car_mock_1.Car.fromJS({ name: 'poet' });
it('no other', function () {
chai_1.expect(car0.getDifference(null)).to.deep.equal(['__no_other__']);
});
it('single diff', function () {
var car1 = car_mock_1.Car.fromJS({ name: 'artist' });
chai_1.expect(car0.getDifference(car1)).to.deep.equal(['name']);
});
it('multi diff (multi)', function () {
var car1 = car_mock_1.Car.fromJS({ name: 'artist', fuel: 'electric' });
chai_1.expect(car0.getDifference(car1)).to.deep.equal(['name', 'fuel']);
});
it('multi diff (single)', function () {
var car1 = car_mock_1.Car.fromJS({ name: 'artist', fuel: 'electric' });
chai_1.expect(car0.getDifference(car1, true)).to.deep.equal(['name']);
});
});
describe('equals', function () {

@@ -74,0 +56,0 @@ it('is not equal if new value is explicitly set', function () {

1

build/keyed-array/keyed-array.d.ts

@@ -7,2 +7,3 @@ export declare type KeyGetter = (x: any) => string;

get(array: T[], key: string): T | undefined;
toMap(array: T[]): Record<string, T>;
checkValid(array: T[], what?: string, where?: string): void;

@@ -9,0 +10,0 @@ isValid(array: T[]): boolean;

@@ -17,8 +17,20 @@ "use strict";

};
KeyedArray.prototype.checkValid = function (array, what, where) {
KeyedArray.prototype.toMap = function (array) {
var getKey = this.getKey;
var seen = {};
var myMap = {};
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
var a = array_1[_i];
var key = getKey(a);
if (myMap[key])
continue;
myMap[key] = a;
}
return myMap;
};
KeyedArray.prototype.checkValid = function (array, what, where) {
var getKey = this.getKey;
var seen = {};
for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
var a = array_2[_i];
var key = getKey(a);
if (seen[key]) {

@@ -35,4 +47,4 @@ throw new Error(['duplicate', what, "'" + key + "'", where ? 'in' : undefined, where]

var seen = {};
for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
var a = array_2[_i];
for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
var a = array_3[_i];
var key = getKey(a);

@@ -39,0 +51,0 @@ if (seen[key])

@@ -52,2 +52,20 @@ "use strict";

});
describe('toMap', function () {
it('works', function () {
expect(keyedHelper.toMap(someArray)).toEqual({
Italy: {
accountId: 'Italy',
score: 3,
},
UK: {
accountId: 'UK',
score: 1,
},
USA: {
accountId: 'USA',
score: 2,
},
});
});
});
});

@@ -35,2 +35,3 @@ export declare type DiffAction = 'create' | 'update' | 'delete';

static get<T extends Nameable>(array: T[], name: string): T;
static toMap<T extends NamedArray>(array: T[]): Record<string, T>;
static containsByName<T extends Nameable>(array: T[], name: string): boolean;

@@ -37,0 +38,0 @@ static findByNameCI<T extends Nameable>(array: T[], name: string): T | undefined;

@@ -76,2 +76,5 @@ "use strict";

};
NamedArray.toMap = function (array) {
return KEYED_ARRAY.toMap(array);
};
NamedArray.containsByName = function (array, name) {

@@ -78,0 +81,0 @@ return simple_array_1.SimpleArray.contains(array, function (x) { return x.name === name; });

@@ -101,9 +101,2 @@ "use strict";

});
it('overrides large', function () {
var overrides = [];
for (var i = 0; i < 40000; i++) {
overrides.push({ name: 'Over' + i, score: i });
}
chai_1.expect(named_array_1.NamedArray.overridesByName(someArray, overrides).length).to.equal(40003);
});
});

@@ -121,2 +114,9 @@ describe("deleteByName", function () {

});
describe("findByName", function () {
it('something that exists', function () {
chai_1.expect(named_array_1.NamedArray.findByName([
{ "name": "khanh-chuong.duong@tabmo.io ", "accountId": "c7e52d4b-b74b-42bf-81b4-168e7e651195", "email": "khanh-chuong.duong@tabmo.io ", "firstName": "khanh-chuong", "lastName": "duong", "roles": ["super-admin"] }
], 'khanh-chuong.duong@tabmo.io ')).to.deep.equal({ name: 'USA', score: 2 });
});
});
describe("findByNameCI", function () {

@@ -123,0 +123,0 @@ it('something that exists', function () {

@@ -136,2 +136,20 @@ "use strict";

});
describe('#toMap', function () {
it('works', function () {
expect(named_array_1.NamedArray.toMap(someArray)).toEqual({
Italy: {
name: 'Italy',
score: 3,
},
UK: {
name: 'UK',
score: 1,
},
USA: {
name: 'USA',
score: 2,
},
});
});
});
describe('synchronize', function () {

@@ -138,0 +156,0 @@ function valueEqual(a, b) {

{
"name": "immutable-class",
"version": "0.9.6",
"version": "0.9.7",
"description": "A template for creating immutable classes",

@@ -5,0 +5,0 @@ "keywords": [

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