@thi.ng/equiv
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="0.1.3"></a> | ||
## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@0.1.2...@thi.ng/equiv@0.1.3) (2018-05-14) | ||
**Note:** Version bump only for package @thi.ng/equiv | ||
<a name="0.1.2"></a> | ||
@@ -8,0 +16,0 @@ ## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@0.1.1...@thi.ng/equiv@0.1.2) (2018-05-14) |
{ | ||
"name": "@thi.ng/equiv", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Extensible deep equivalence checking for any data types", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -43,2 +43,35 @@ # @thi.ng/equiv | ||
### Implement IEquiv interface | ||
This is useful & required for custom types to take part in `equiv` | ||
checks, by default only plain objects & array are traversed deeply. | ||
Furthemore by implementing this interface we can better control which | ||
internal values / criteria are required to establish equivalence. In | ||
this example we exclude the `meta` property and only check for same type | ||
& `children` equality. | ||
```ts | ||
import { IEquiv } from "@thi.ng/api"; | ||
import { equiv } from "@thi.ng/equiv"; | ||
class Node implements IEquiv { | ||
meta: any; | ||
children: any[]; | ||
constructor(children: any[], meta?) { | ||
this.children = children; | ||
this.meta = meta; | ||
} | ||
equiv(o: any) { | ||
return o instanceof Node && equiv(this.children, o.children); | ||
} | ||
} | ||
equiv(new Node([1,2,3], "foo"), new Node([1,2,3], "bar")); | ||
// true | ||
``` | ||
## Authors | ||
@@ -45,0 +78,0 @@ |
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
17559
83