This commit is contained in:
2023-09-14 18:19:36 +03:00
parent 4bc155683b
commit 58770bf89f
13 changed files with 164 additions and 77 deletions

28
src/utils/objects.ts Normal file
View File

@@ -0,0 +1,28 @@
export const isEqual = <T extends object>(objects: T[]) => {
for (let i = 0; i < objects.length; i++) {
const obj1 = objects[i]
const obj2 = objects[i + 1]
if (obj2) {
const keys1 = Object.keys(obj1)
const keys2 = Object.keys(obj2)
if (keys1.length !== keys2.length) {
return false
}
for(const key of keys1) {
if (typeof obj1[key] !== 'object') {
if (obj1[key] !== obj2[key]) {
return false
}
} else {
if (!isEqual([obj1[key], obj2[key]])) {
return false
}
}
}
}
}
return true
}