immutable-class
Advanced tools
Comparing version 0.7.4 to 0.7.5
@@ -64,4 +64,4 @@ export interface Validator { | ||
toString(): string; | ||
getDifference(other: BaseImmutable<ValueType, JSType>, ignore?: string[]): string; | ||
equals(other: BaseImmutable<ValueType, JSType>, ignore?: string[]): boolean; | ||
getDifference(other: BaseImmutable<ValueType, JSType>, returnOnFirstDifference?: boolean): string[]; | ||
equals(other: BaseImmutable<ValueType, JSType>): boolean; | ||
equivalent(other: BaseImmutable<ValueType, JSType>): boolean; | ||
@@ -68,0 +68,0 @@ get(propName: string): any; |
@@ -179,24 +179,26 @@ "use strict"; | ||
}; | ||
BaseImmutable.prototype.getDifference = function (other, ignore) { | ||
if (ignore === void 0) { ignore = []; } | ||
BaseImmutable.prototype.getDifference = function (other, returnOnFirstDifference) { | ||
if (returnOnFirstDifference === void 0) { returnOnFirstDifference = false; } | ||
if (!other) | ||
return 'No other (!other)'; | ||
return ['No other (!other)']; | ||
if (this === other) | ||
return ''; | ||
return []; | ||
if (!(other instanceof this.constructor)) | ||
return 'Different constructors'; | ||
return ['Different constructors']; | ||
var differences = []; | ||
var properties = this.ownProperties(); | ||
for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { | ||
var property = properties_5[_i]; | ||
if (ignore.indexOf(property.name) > -1) | ||
continue; | ||
var equal = property.equal || equality_1.generalEqual; | ||
if (!equal(this[property.name], other[property.name])) { | ||
return 'Different property: ' + property.name; | ||
var difference = 'Different property: ' + property.name; | ||
if (returnOnFirstDifference) | ||
return [difference]; | ||
differences.push(difference); | ||
} | ||
} | ||
return ''; | ||
return differences; | ||
}; | ||
BaseImmutable.prototype.equals = function (other, ignore) { | ||
return !this.getDifference(other, ignore); | ||
BaseImmutable.prototype.equals = function (other) { | ||
return this.getDifference(other, true).length === 0; | ||
}; | ||
@@ -203,0 +205,0 @@ BaseImmutable.prototype.equivalent = function (other) { |
{ | ||
"name": "immutable-class", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"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
91539
1923