fast-equals
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -120,2 +120,23 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/** | ||
* @function areIterablesEqual | ||
* | ||
* @description | ||
* determine if the iterables are equivalent in value | ||
* | ||
* @param {Map|Set} objectA the object to test | ||
* @param {Map|Set} objectB the object to test against | ||
* @param {function} comparator the comparator to determine deep equality | ||
* @returns {boolean} are the objects equal in value | ||
*/ | ||
var areIterablesEqual = exports.areIterablesEqual = function areIterablesEqual(objectA, objectB, comparator) { | ||
if (objectA.size !== objectB.size) { | ||
return false; | ||
} | ||
var pairsA = toPairs(objectA); | ||
var pairsB = toPairs(objectB); | ||
return comparator(pairsA.keys, pairsB.keys) && comparator(pairsA.values, pairsB.values); | ||
}; | ||
/***/ }), | ||
@@ -170,2 +191,6 @@ /* 1 */ | ||
var HAS_MAP_SUPPORT = typeof Map === 'function'; // utils | ||
var HAS_SET_SUPPORT = typeof Set === 'function'; | ||
var createComparator = function createComparator(createIsEqual) { | ||
@@ -229,14 +254,18 @@ var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator; // eslint-disable-line | ||
var iterableA = typeof objectA.forEach === 'function'; | ||
var iterableB = typeof objectB.forEach === 'function'; | ||
if (HAS_MAP_SUPPORT) { | ||
var mapA = objectA instanceof Map; | ||
var mapB = objectB instanceof Map; | ||
if (iterableA || iterableB) { | ||
if (iterableA !== iterableB || objectA.size !== objectB.size) { | ||
return false; | ||
if (mapA || mapB) { | ||
return mapA === mapB && (0, _utils.areIterablesEqual)(objectA, objectB, comparator); | ||
} | ||
} | ||
var pairsA = (0, _utils.toPairs)(objectA); | ||
var pairsB = (0, _utils.toPairs)(objectB); | ||
if (HAS_SET_SUPPORT) { | ||
var setA = objectA instanceof Set; | ||
var setB = objectB instanceof Set; | ||
return comparator(pairsA.keys, pairsB.keys) && comparator(pairsA.values, pairsB.values); | ||
if (setA || setB) { | ||
return setA === setB && (0, _utils.areIterablesEqual)(objectA, objectB, comparator); | ||
} | ||
} | ||
@@ -267,3 +296,4 @@ | ||
return comparator; | ||
}; // utils | ||
}; | ||
exports.default = createComparator; | ||
@@ -270,0 +300,0 @@ |
@@ -1,1 +0,1 @@ | ||
!(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("fe",[],t):"object"==typeof exports?exports.fe=t():e.fe=t()})(this,(function(){return (function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)})([(function(e,t,r){"use strict";t.__esModule=!0;t.createIsStrictlyEqual=function(){return function(e,t){return e===t}},t.toPairs=function(e){var t={keys:new Array(e.size),values:new Array(e.size)},r=0;return e.forEach((function(e,n){t.keys[r]=n,t.values[r]=e,r++})),t}}),(function(e,t,r){e.exports=r(2)}),(function(e,t,r){"use strict";t.__esModule=!0,t.shallowEqual=t.deepEqual=t.createCustomEqual=void 0;var n=r(3),o=(function(e){return e&&e.__esModule?e:{default:e}})(n),u=r(0),a=t.createCustomEqual=o.default,i=t.deepEqual=(0,o.default)(),f=t.shallowEqual=(0,o.default)(u.createIsStrictlyEqual);t.default={createCustom:a,deep:i,shallow:f}}),(function(e,t,r){"use strict";t.__esModule=!0;var n=r(0),o=function(e){function t(e,o){if(e===o)return!0;var u=typeof e;if(u!==typeof o)return!1;if("object"===u&&e&&o){var a=Array.isArray(e),i=Array.isArray(o),f=void 0;if(a||i){if(a!==i||e.length!==o.length)return!1;for(f=0;f<e.length;f++)if(!r(e[f],o[f]))return!1;return!0}var s=e instanceof Date,l=o instanceof Date;if(s||l)return s===l&&e.getTime()===o.getTime();var c=e instanceof RegExp,p=o instanceof RegExp;if(c||p)return c===p&&e.source===o.source&&e.global===o.global&&e.ignoreCase===o.ignoreCase&&e.multiline===o.multiline;var y="function"==typeof e.forEach,d="function"==typeof o.forEach;if(y||d){if(y!==d||e.size!==o.size)return!1;var v=(0,n.toPairs)(e),g=(0,n.toPairs)(o);return t(v.keys,g.keys)&&t(v.values,g.values)}var h=Object.keys(e);if(h.length!==Object.keys(o).length)return!1;var b=void 0;for(f=0;f<h.length;f++)if(b=h[f],!Object.prototype.hasOwnProperty.call(o,b)||!r(e[b],o[b]))return!1;return!0}return e!==e&&o!==o}var r="function"==typeof e?e(t):t;return t};t.default=o})])})); | ||
!(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("fe",[],t):"object"==typeof exports?exports.fe=t():e.fe=t()})(this,(function(){return (function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,t),u.l=!0,u.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)})([(function(e,t,r){"use strict";t.__esModule=!0;var n=(t.createIsStrictlyEqual=function(){return function(e,t){return e===t}},t.toPairs=function(e){var t={keys:new Array(e.size),values:new Array(e.size)},r=0;return e.forEach((function(e,n){t.keys[r]=n,t.values[r]=e,r++})),t});t.areIterablesEqual=function(e,t,r){if(e.size!==t.size)return!1;var u=n(e),o=n(t);return r(u.keys,o.keys)&&r(u.values,o.values)}}),(function(e,t,r){e.exports=r(2)}),(function(e,t,r){"use strict";t.__esModule=!0,t.shallowEqual=t.deepEqual=t.createCustomEqual=void 0;var n=r(3),u=(function(e){return e&&e.__esModule?e:{default:e}})(n),o=r(0),a=t.createCustomEqual=u.default,i=t.deepEqual=(0,u.default)(),f=t.shallowEqual=(0,u.default)(o.createIsStrictlyEqual);t.default={createCustom:a,deep:i,shallow:f}}),(function(e,t,r){"use strict";t.__esModule=!0;var n=r(0),u="function"==typeof Map,o="function"==typeof Set,a=function(e){function t(e,a){if(e===a)return!0;var i=typeof e;if(i!==typeof a)return!1;if("object"===i&&e&&a){var f=Array.isArray(e),s=Array.isArray(a),l=void 0;if(f||s){if(f!==s||e.length!==a.length)return!1;for(l=0;l<e.length;l++)if(!r(e[l],a[l]))return!1;return!0}var c=e instanceof Date,p=a instanceof Date;if(c||p)return c===p&&e.getTime()===a.getTime();var y=e instanceof RegExp,d=a instanceof RegExp;if(y||d)return y===d&&e.source===a.source&&e.global===a.global&&e.ignoreCase===a.ignoreCase&&e.multiline===a.multiline;if(u){var v=e instanceof Map,b=a instanceof Map;if(v||b)return v===b&&(0,n.areIterablesEqual)(e,a,t)}if(o){var g=e instanceof Set,E=a instanceof Set;if(g||E)return g===E&&(0,n.areIterablesEqual)(e,a,t)}var h=Object.keys(e);if(h.length!==Object.keys(a).length)return!1;var m=void 0;for(l=0;l<h.length;l++)if(m=h[l],!Object.prototype.hasOwnProperty.call(a,m)||!r(e[m],a[m]))return!1;return!0}return e!==e&&a!==a}var r="function"==typeof e?e(t):t;return t};t.default=a})])})); |
// utils | ||
import { toPairs } from './utils'; | ||
import { areIterablesEqual } from './utils'; | ||
var HAS_MAP_SUPPORT = typeof Map === 'function'; | ||
var HAS_SET_SUPPORT = typeof Set === 'function'; | ||
var createComparator = function createComparator(createIsEqual) { | ||
@@ -62,14 +65,18 @@ var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator; // eslint-disable-line | ||
var iterableA = typeof objectA.forEach === 'function'; | ||
var iterableB = typeof objectB.forEach === 'function'; | ||
if (HAS_MAP_SUPPORT) { | ||
var mapA = objectA instanceof Map; | ||
var mapB = objectB instanceof Map; | ||
if (iterableA || iterableB) { | ||
if (iterableA !== iterableB || objectA.size !== objectB.size) { | ||
return false; | ||
if (mapA || mapB) { | ||
return mapA === mapB && areIterablesEqual(objectA, objectB, comparator); | ||
} | ||
} | ||
var pairsA = toPairs(objectA); | ||
var pairsB = toPairs(objectB); | ||
if (HAS_SET_SUPPORT) { | ||
var setA = objectA instanceof Set; | ||
var setB = objectB instanceof Set; | ||
return comparator(pairsA.keys, pairsB.keys) && comparator(pairsA.values, pairsB.values); | ||
if (setA || setB) { | ||
return setA === setB && areIterablesEqual(objectA, objectB, comparator); | ||
} | ||
} | ||
@@ -76,0 +83,0 @@ |
@@ -35,2 +35,23 @@ export var createIsStrictlyEqual = function createIsStrictlyEqual() { | ||
return pairs; | ||
}; | ||
/** | ||
* @function areIterablesEqual | ||
* | ||
* @description | ||
* determine if the iterables are equivalent in value | ||
* | ||
* @param {Map|Set} objectA the object to test | ||
* @param {Map|Set} objectB the object to test against | ||
* @param {function} comparator the comparator to determine deep equality | ||
* @returns {boolean} are the objects equal in value | ||
*/ | ||
export var areIterablesEqual = function areIterablesEqual(objectA, objectB, comparator) { | ||
if (objectA.size !== objectB.size) { | ||
return false; | ||
} | ||
var pairsA = toPairs(objectA); | ||
var pairsB = toPairs(objectB); | ||
return comparator(pairsA.keys, pairsB.keys) && comparator(pairsA.values, pairsB.values); | ||
}; |
@@ -7,2 +7,6 @@ 'use strict'; | ||
var HAS_MAP_SUPPORT = typeof Map === 'function'; // utils | ||
var HAS_SET_SUPPORT = typeof Set === 'function'; | ||
var createComparator = function createComparator(createIsEqual) { | ||
@@ -66,14 +70,18 @@ var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator; // eslint-disable-line | ||
var iterableA = typeof objectA.forEach === 'function'; | ||
var iterableB = typeof objectB.forEach === 'function'; | ||
if (HAS_MAP_SUPPORT) { | ||
var mapA = objectA instanceof Map; | ||
var mapB = objectB instanceof Map; | ||
if (iterableA || iterableB) { | ||
if (iterableA !== iterableB || objectA.size !== objectB.size) { | ||
return false; | ||
if (mapA || mapB) { | ||
return mapA === mapB && (0, _utils.areIterablesEqual)(objectA, objectB, comparator); | ||
} | ||
} | ||
var pairsA = (0, _utils.toPairs)(objectA); | ||
var pairsB = (0, _utils.toPairs)(objectB); | ||
if (HAS_SET_SUPPORT) { | ||
var setA = objectA instanceof Set; | ||
var setB = objectB instanceof Set; | ||
return comparator(pairsA.keys, pairsB.keys) && comparator(pairsA.values, pairsB.values); | ||
if (setA || setB) { | ||
return setA === setB && (0, _utils.areIterablesEqual)(objectA, objectB, comparator); | ||
} | ||
} | ||
@@ -104,3 +112,4 @@ | ||
return comparator; | ||
}; // utils | ||
}; | ||
exports.default = createComparator; |
@@ -38,2 +38,23 @@ "use strict"; | ||
return pairs; | ||
}; | ||
/** | ||
* @function areIterablesEqual | ||
* | ||
* @description | ||
* determine if the iterables are equivalent in value | ||
* | ||
* @param {Map|Set} objectA the object to test | ||
* @param {Map|Set} objectB the object to test against | ||
* @param {function} comparator the comparator to determine deep equality | ||
* @returns {boolean} are the objects equal in value | ||
*/ | ||
var areIterablesEqual = exports.areIterablesEqual = function areIterablesEqual(objectA, objectB, comparator) { | ||
if (objectA.size !== objectB.size) { | ||
return false; | ||
} | ||
var pairsA = toPairs(objectA); | ||
var pairsB = toPairs(objectB); | ||
return comparator(pairsA.keys, pairsB.keys) && comparator(pairsA.values, pairsB.values); | ||
}; |
@@ -90,3 +90,3 @@ { | ||
}, | ||
"version": "1.0.2" | ||
"version": "1.0.3" | ||
} |
Sorry, the diff of this file is not supported yet
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
44428
530