@spaced-out/ui-design-system
Version:
Sense UI components library
15 lines (12 loc) • 346 B
Flow
// @flow strict
type ItemComparer<Item> = (a: Item, b: Item) => boolean;
export function areArraysEqual<Item>(
array1: Item[],
array2: Item[],
itemComparer: ItemComparer<Item> = (a, b) => a === b,
): boolean {
return (
array1.length === array2.length &&
array1.every((value, index) => itemComparer(value, array2[index]))
);
}