@thi.ng/equiv
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.0.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@1.0.8...@thi.ng/equiv@1.0.9) (2019-07-31) | ||
**Note:** Version bump only for package @thi.ng/equiv | ||
## [1.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@1.0.7...@thi.ng/equiv@1.0.8) (2019-07-12) | ||
@@ -8,0 +16,0 @@ |
@@ -1,88 +0,1 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory((global.thi = global.thi || {}, global.thi.ng = global.thi.ng || {}, global.thi.ng.equiv = {}))); | ||
}(this, function (exports) { 'use strict'; | ||
const OBJP = Object.getPrototypeOf({}); | ||
const FN = "function"; | ||
const STR = "string"; | ||
const equiv = (a, b) => { | ||
let proto; | ||
if (a === b) { | ||
return true; | ||
} | ||
if (a != null) { | ||
if (typeof a.equiv === FN) { | ||
return a.equiv(b); | ||
} | ||
} | ||
else { | ||
return a == b; | ||
} | ||
if (b != null) { | ||
if (typeof b.equiv === FN) { | ||
return b.equiv(a); | ||
} | ||
} | ||
else { | ||
return a == b; | ||
} | ||
if (typeof a === STR || typeof b === STR) { | ||
return false; | ||
} | ||
if (((proto = Object.getPrototypeOf(a)), proto == null || proto === OBJP) && | ||
((proto = Object.getPrototypeOf(b)), proto == null || proto === OBJP)) { | ||
return equivObject(a, b); | ||
} | ||
if (typeof a !== FN && | ||
a.length !== undefined && | ||
typeof b !== FN && | ||
b.length !== undefined) { | ||
return equivArrayLike(a, b); | ||
} | ||
if (a instanceof Set && b instanceof Set) { | ||
return equivSet(a, b); | ||
} | ||
if (a instanceof Map && b instanceof Map) { | ||
return equivMap(a, b); | ||
} | ||
if (a instanceof Date && b instanceof Date) { | ||
return a.getTime() === b.getTime(); | ||
} | ||
if (a instanceof RegExp && b instanceof RegExp) { | ||
return a.toString() === b.toString(); | ||
} | ||
return a !== a && b !== b; | ||
}; | ||
const equivArrayLike = (a, b, _equiv = equiv) => { | ||
let l = a.length; | ||
if (l === b.length) { | ||
while (--l >= 0 && _equiv(a[l], b[l])) | ||
; | ||
} | ||
return l < 0; | ||
}; | ||
const equivSet = (a, b, _equiv = equiv) => a.size === b.size && _equiv([...a.keys()].sort(), [...b.keys()].sort()); | ||
const equivMap = (a, b, _equiv = equiv) => a.size === b.size && _equiv([...a].sort(), [...b].sort()); | ||
const equivObject = (a, b, _equiv = equiv) => { | ||
if (Object.keys(a).length !== Object.keys(b).length) { | ||
return false; | ||
} | ||
for (let k in a) { | ||
if (!b.hasOwnProperty(k) || !_equiv(a[k], b[k])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
exports.equiv = equiv; | ||
exports.equivArrayLike = equivArrayLike; | ||
exports.equivMap = equivMap; | ||
exports.equivObject = equivObject; | ||
exports.equivSet = equivSet; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.equiv={}))}(this,function(e){"use strict";const t=Object.getPrototypeOf({}),n="function",i=(e,i)=>{let u;return e===i||(null==e?e==i:typeof e.equiv===n?e.equiv(i):null==i?e==i:typeof i.equiv===n?i.equiv(e):"string"!=typeof e&&"string"!=typeof i&&(null!=(u=Object.getPrototypeOf(e))&&u!==t||null!=(u=Object.getPrototypeOf(i))&&u!==t?typeof e!==n&&void 0!==e.length&&typeof i!==n&&void 0!==i.length?o(e,i):e instanceof Set&&i instanceof Set?f(e,i):e instanceof Map&&i instanceof Map?r(e,i):e instanceof Date&&i instanceof Date?e.getTime()===i.getTime():e instanceof RegExp&&i instanceof RegExp?e.toString()===i.toString():e!=e&&i!=i:s(e,i)))},o=(e,t,n=i)=>{let o=e.length;if(o===t.length)for(;--o>=0&&n(e[o],t[o]););return o<0},f=(e,t,n=i)=>e.size===t.size&&n([...e.keys()].sort(),[...t.keys()].sort()),r=(e,t,n=i)=>e.size===t.size&&n([...e].sort(),[...t].sort()),s=(e,t,n=i)=>{if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!t.hasOwnProperty(i)||!n(e[i],t[i]))return!1;return!0};e.equiv=i,e.equivArrayLike=o,e.equivMap=r,e.equivObject=s,e.equivSet=f,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@thi.ng/equiv", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Extensible deep equivalence checking for any data types", | ||
@@ -17,14 +17,15 @@ "module": "./index.js", | ||
"scripts": { | ||
"build": "yarn clean && yarn build:es6 && yarn build:bundle", | ||
"build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module", | ||
"build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all", | ||
"build:es6": "tsc --declaration", | ||
"build:bundle": "../../scripts/bundle-module", | ||
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", | ||
"build:test": "rimraf build && tsc -p test/tsconfig.json", | ||
"test": "yarn build:test && mocha build/test/*.js", | ||
"cover": "yarn build:test && nyc mocha build/test/*.js && nyc report --reporter=lcov", | ||
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", | ||
"cover": "yarn test && nyc report --reporter=lcov", | ||
"doc": "node_modules/.bin/typedoc --mode modules --out doc --ignoreCompilerErrors src", | ||
"pub": "yarn build && yarn publish --access public" | ||
"pub": "yarn build:release && yarn publish --access public" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^12.0.8", | ||
"@types/node": "^12.6.3", | ||
"benchmark": "^2.1.4", | ||
@@ -34,3 +35,3 @@ "mocha": "^6.1.4", | ||
"typedoc": "^0.14.2", | ||
"typescript": "^3.5.2" | ||
"typescript": "^3.5.3" | ||
}, | ||
@@ -58,3 +59,3 @@ "keywords": [ | ||
"sideEffects": false, | ||
"gitHead": "47075afc37f3a16adee7c903a2935304c7cf5daf" | ||
"gitHead": "53eec7988c378fc37ae140e7174f36ef9b6208fe" | ||
} |
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
32593
257