Skip to content

Commit 0835af6

Browse files
committed
perf: optimize getIntersection
1 parent 4f6e6f0 commit 0835af6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/utilities-data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export function getIntersection<T>(items: T[][] = []): T[] {
1111
return firstItem;
1212
}
1313
return otherItems.reduce((accumulator, currentValue) => {
14-
return accumulator.filter((item) => currentValue.includes(item));
14+
const currentSet = new Set(currentValue);
15+
return accumulator.filter((item) => currentSet.has(item));
1516
}, firstItem);
1617
}
1718

0 commit comments

Comments
 (0)