File size: 385 Bytes
d9494a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export const compareArraysOfObjectsByProperty = <T, K extends keyof T>(
  arrayA: T[],
  arrayB: T[],
  property: K,
) => {
  return (
    arrayA.length !== arrayB.length ||
    arrayA.some(
      (item) => !arrayB.some((itemB) => itemB[property] === item[property]),
    ) ||
    arrayB.some(
      (item) => !arrayA.some((itemA) => itemA[property] === item[property]),
    )
  );
};