Skip to content

Commit

Permalink
document and format equals utility
Browse files Browse the repository at this point in the history
  • Loading branch information
park-brian committed Dec 21, 2024
1 parent f1ee025 commit 17431f4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ export function concat(aaa, bbb) {

/**
* Deep equality comparison
*
* @param {any} a
* @param {any} b
* @returns {boolean}
*
* @param {any} a First object to compare
* @param {any} b Second object to compare
* @returns {boolean} true if objects are equal
*/
export function equals(a, b) {
if (a === b) return true;
if (!a || !b || typeof a !== typeof b) return false;
return Array.isArray(a)
if (a === b) return true
if (!a || !b || typeof a !== typeof b) return false
return Array.isArray(a)
? a.length === b.length && a.every((v, i) => equals(v, b[i]))
: Object.keys(a).length === Object.keys(b).length && Object.keys(a).every(k => equals(a[k], b[k]));
: Object.keys(a).length === Object.keys(b).length && Object.keys(a).every(k => equals(a[k], b[k]))
}

/**
Expand Down

0 comments on commit 17431f4

Please sign in to comment.