immutable-class
Advanced tools
Comparing version 0.9.7 to 0.9.8
@@ -7,3 +7,3 @@ export declare type KeyGetter = (x: any) => string; | ||
get(array: T[], key: string): T | undefined; | ||
toMap(array: T[]): Record<string, T>; | ||
toRecord(array: T[]): Record<string, T>; | ||
checkValid(array: T[], what?: string, where?: string): void; | ||
@@ -10,0 +10,0 @@ isValid(array: T[]): boolean; |
@@ -17,13 +17,13 @@ "use strict"; | ||
}; | ||
KeyedArray.prototype.toMap = function (array) { | ||
KeyedArray.prototype.toRecord = function (array) { | ||
var getKey = this.getKey; | ||
var myMap = {}; | ||
var myRecord = {}; | ||
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { | ||
var a = array_1[_i]; | ||
var key = getKey(a); | ||
if (myMap[key]) | ||
if (myRecord[key]) | ||
continue; | ||
myMap[key] = a; | ||
myRecord[key] = a; | ||
} | ||
return myMap; | ||
return myRecord; | ||
}; | ||
@@ -30,0 +30,0 @@ KeyedArray.prototype.checkValid = function (array, what, where) { |
@@ -54,3 +54,3 @@ "use strict"; | ||
it('works', function () { | ||
expect(keyedHelper.toMap(someArray)).toEqual({ | ||
expect(keyedHelper.toRecord(someArray)).toEqual({ | ||
Italy: { | ||
@@ -57,0 +57,0 @@ accountId: 'Italy', |
@@ -35,3 +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 toRecord<T extends NamedArray>(array: T[]): Record<string, T>; | ||
static containsByName<T extends Nameable>(array: T[], name: string): boolean; | ||
@@ -38,0 +38,0 @@ static findByNameCI<T extends Nameable>(array: T[], name: string): T | undefined; |
@@ -76,4 +76,4 @@ "use strict"; | ||
}; | ||
NamedArray.toMap = function (array) { | ||
return KEYED_ARRAY.toMap(array); | ||
NamedArray.toRecord = function (array) { | ||
return KEYED_ARRAY.toRecord(array); | ||
}; | ||
@@ -80,0 +80,0 @@ NamedArray.containsByName = function (array, name) { |
@@ -138,3 +138,3 @@ "use strict"; | ||
it('works', function () { | ||
expect(named_array_1.NamedArray.toMap(someArray)).toEqual({ | ||
expect(named_array_1.NamedArray.toRecord(someArray)).toEqual({ | ||
Italy: { | ||
@@ -141,0 +141,0 @@ name: 'Italy', |
{ | ||
"name": "immutable-class", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"description": "A template for creating immutable classes", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
137991