-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Marco Gomez <[email protected]>
- Loading branch information
1 parent
5cac31d
commit 9ae0a23
Showing
22 changed files
with
2,370 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Originally from https://github.com/chbrown/rfc6902 | ||
|
||
Combined with this contribution from supermeng: https://github.com/chbrown/rfc6902/pull/88/files | ||
|
||
Vendored here to avoid depending on a unpublished git repository. | ||
|
||
# License | ||
|
||
Copyright 2014-2021 Christopher Brown. MIT Licensed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export function deepEqual(a: any, b: any): boolean { | ||
if (a === b) { | ||
return true; | ||
} | ||
|
||
if (Array.isArray(a) && Array.isArray(b)) { | ||
if (a.length !== b.length) { | ||
return false; | ||
} | ||
|
||
return a.every((elem, index) => { | ||
return deepEqual(elem, b[index]); | ||
}); | ||
} | ||
|
||
if (typeof a === "object" && typeof b === "object" && a !== null && b !== null) { | ||
if (Array.isArray(a) || Array.isArray(b)) { | ||
return false; | ||
} | ||
|
||
const keys1 = Object.keys(a); | ||
const keys2 = Object.keys(b); | ||
if (keys1.length !== keys2.length || !keys1.every((key) => keys2.includes(key))) { | ||
return false; | ||
} | ||
|
||
for (const key in a) { | ||
if (!deepEqual(a[key], b[key])) { | ||
return false; | ||
} | ||
} | ||
|
||
if (keys1.length === 0 && a instanceof Date && b instanceof Date) { | ||
// Only need to check the length of 1 as they are already known to be equal | ||
return a.getTime() === b.getTime(); | ||
} | ||
|
||
return true; | ||
} | ||
return false; | ||
} |
Oops, something went wrong.