@thi.ng/api
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="2.3.0"></a> | ||
# [2.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.2.0...@thi.ng/api@2.3.0) (2018-04-26) | ||
### Features | ||
* **api:** support more types in equiv(), add tests ([2ac8bff](https://github.com/thi-ng/umbrella/commit/2ac8bff)) | ||
<a name="2.2.0"></a> | ||
@@ -8,0 +19,0 @@ # [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.1.3...@thi.ng/api@2.2.0) (2018-04-08) |
21
equiv.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const is_arraylike_1 = require("@thi.ng/checks/is-arraylike"); | ||
const is_date_1 = require("@thi.ng/checks/is-date"); | ||
const is_map_1 = require("@thi.ng/checks/is-map"); | ||
const is_plain_object_1 = require("@thi.ng/checks/is-plain-object"); | ||
const is_regexp_1 = require("@thi.ng/checks/is-regexp"); | ||
const is_set_1 = require("@thi.ng/checks/is-set"); | ||
function equiv(a, b) { | ||
@@ -34,3 +38,13 @@ if (a === b) { | ||
} | ||
return false; | ||
if ((is_set_1.isSet(a) && is_set_1.isSet(b)) || (is_map_1.isMap(a) && is_map_1.isMap(b))) { | ||
return equivSetLike(a, b); | ||
} | ||
if (is_date_1.isDate(a) && is_date_1.isDate(b)) { | ||
return a.getTime() === b.getTime(); | ||
} | ||
if (is_regexp_1.isRegExp(a) && is_regexp_1.isRegExp(b)) { | ||
return a.toString() === b.toString(); | ||
} | ||
// NaN | ||
return (a !== a && b !== b); | ||
} | ||
@@ -46,2 +60,7 @@ exports.equiv = equiv; | ||
} | ||
function equivSetLike(a, b) { | ||
if (a.size !== b.size) | ||
return false; | ||
return equiv([...a].sort(), [...b].sort()); | ||
} | ||
function equivObject(a, b) { | ||
@@ -48,0 +67,0 @@ const keys = new Set(Object.keys(a).concat(Object.keys(b))); |
{ | ||
"name": "@thi.ng/api", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Common, generic types & interfaces for thi.ng projects", | ||
@@ -27,3 +27,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@thi.ng/checks": "^1.4.0" | ||
"@thi.ng/checks": "^1.5.0" | ||
}, | ||
@@ -30,0 +30,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
41074
842
Updated@thi.ng/checks@^1.5.0