@thi.ng/api
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="2.3.1"></a> | ||
## [2.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.3.0...@thi.ng/api@2.3.1) (2018-04-29) | ||
### Performance Improvements | ||
* **api:** major speedup equivObject(), update equivSet() ([7fdf172](https://github.com/thi-ng/umbrella/commit/7fdf172)) | ||
<a name="2.3.0"></a> | ||
@@ -8,0 +19,0 @@ # [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) |
30
equiv.js
@@ -38,5 +38,8 @@ "use strict"; | ||
} | ||
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_set_1.isSet(a) && is_set_1.isSet(b)) { | ||
return equivSet(a, b); | ||
} | ||
if (is_map_1.isMap(a) && is_map_1.isMap(b)) { | ||
return equivMap(a, b); | ||
} | ||
if (is_date_1.isDate(a) && is_date_1.isDate(b)) { | ||
@@ -60,20 +63,23 @@ return a.getTime() === b.getTime(); | ||
} | ||
function equivSetLike(a, b) { | ||
function equivSet(a, b) { | ||
if (a.size !== b.size) | ||
return false; | ||
return equiv([...a.keys()].sort(), [...b.keys()].sort()); | ||
} | ||
function equivMap(a, b) { | ||
if (a.size !== b.size) | ||
return false; | ||
return equiv([...a].sort(), [...b].sort()); | ||
} | ||
function equivObject(a, b) { | ||
const keys = new Set(Object.keys(a).concat(Object.keys(b))); | ||
for (let k of keys) { | ||
if (a.hasOwnProperty(k)) { | ||
if (b.hasOwnProperty(k)) { | ||
if (equiv(a[k], b[k])) { | ||
continue; | ||
} | ||
} | ||
const ka = Object.keys(a); | ||
if (ka.length !== Object.keys(b).length) | ||
return false; | ||
for (let i = ka.length, k; --i >= 0;) { | ||
k = ka[i]; | ||
if (!b.hasOwnProperty(k) || !equiv(a[k], b[k])) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
return true; | ||
} |
{ | ||
"name": "@thi.ng/api", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Common, generic types & interfaces for thi.ng projects", | ||
@@ -27,3 +27,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@thi.ng/checks": "^1.5.0" | ||
"@thi.ng/checks": "^1.5.1" | ||
}, | ||
@@ -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
41485
848
Updated@thi.ng/checks@^1.5.1