json-deep-compare
Version:
A powerful library for comparing JSON objects with support for deep comparison, regex validation, and customizable options
1 lines • 726 B
JavaScript
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){const o=r.length;if(o!==e.length)return!1;if(0===o)return!0;for(let t=0;t<o;t++)if(!this.booleanCompare(r[t],e[t]))return!1;return!0}static booleanCompareObjects(r,e){const o=Object.keys(r),t=Object.keys(e),a=o.length;if(a!==t.length)return!1;if(0===a)return!0;for(let t=0;t<a;t++){const a=o[t];if(!Object.prototype.hasOwnProperty.call(e,a)||!this.booleanCompare(r[a],e[a]))return!1}return!0}}module.exports=BooleanComparator;