Raw
1 /**
2 * Get the difference between two sets. The difference is the elements that are in the original set but not in the compare set.
3 * @param originalSet
4 * @param compareSet
5 */
6 export function getSetDifference<T>(
7 originalSet: Set<T>,
8 compareSet: Set<T>
9 ): Set<T> {
10 const difference = new Set<T>()
11
12 originalSet.forEach((element) => {
13 if (!compareSet.has(element)) {
14 difference.add(element)
15 }
16 })
17
18 return difference
19 }