diff options
author | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-02 16:04:13 -0600 |
---|---|---|
committer | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-02 16:04:13 -0600 |
commit | 5a55b5fa0c678ff03842d2adec8543e754546718 (patch) | |
tree | 4f615829acc10045d81a9d553c757a14792bf81a /src/utils/objectEquivalence.js | |
parent | 4d34b0b4b890e957030fbf6e3c8e1d4a02d2a627 (diff) | |
download | bbiy-5a55b5fa0c678ff03842d2adec8543e754546718.tar.gz bbiy-5a55b5fa0c678ff03842d2adec8543e754546718.zip |
Grid system & simple physics
Diffstat (limited to 'src/utils/objectEquivalence.js')
-rw-r--r-- | src/utils/objectEquivalence.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/objectEquivalence.js b/src/utils/objectEquivalence.js new file mode 100644 index 0000000..e33dd76 --- /dev/null +++ b/src/utils/objectEquivalence.js @@ -0,0 +1,14 @@ +const equivalence = (obj1, obj2) => { + if (obj1 === null) { + return obj1 === null; + } + return Object.keys(obj1).every(key => { + if (obj2[key] === undefined) { + return false; + } + if (typeof obj1[key] === 'object') { + return equivalence(obj1[key], obj2[key]); + } + return obj1[key] === obj2[key]; + }); +}; |