UNPKG

json-deep-compare

Version:

A powerful library for comparing JSON objects with support for deep comparison, regex validation, and customizable options

1 lines 720 B
class BooleanComparator{static booleanCompare(r,e){return r===e||typeof r==typeof e&&(null==r||null==e||"object"!=typeof r?r===e:Array.isArray(r)===Array.isArray(e)&&(Array.isArray(r)&&Array.isArray(e)?this.booleanCompareArrays(r,e):this.booleanCompareObjects(r,e)))}static booleanCompareArrays(r,e){var a=r.length;if(a!==e.length)return!1;if(0===a)return!0;for(var o=0;o<a;o++)if(!this.booleanCompare(r[o],e[o]))return!1;return!0}static booleanCompareObjects(r,e){var a=Object.keys(r),o=Object.keys(e),t=a.length;if(t!==o.length)return!1;if(0===t)return!0;for(var n=0;n<t;n++){var l=a[n];if(!Object.prototype.hasOwnProperty.call(e,l)||!this.booleanCompare(r[l],e[l]))return!1}return!0}}module.exports=BooleanComparator;