export function intersection < T > ( setA , setB ) { const intersecting = new Set < T > ( ) ; for ( const elem of setB ) { if ( setA . has ( elem ) ) { intersecting . add ( elem ) ; } } return intersecting ; } export function difference < T > ( setA , setB ) { const diff = new Set ( setA ) ; setB . forEach ( ( item ) => diff . delete ( item ) ) ; return diff ; } export function union < T > ( setA , setB ) { const unionSet = new Set ( setA ) ; setB . forEach ( ( item ) => unionSet . add ( item ) ) ; return unionSet ; }