export function pullFromSet < T > ( set , capacity ) { if ( capacity > 0 && set . size > 0 ) { const values = [ ] ; for ( const value of set ) { if ( set . delete ( value ) ) { values . push ( value ) ; if ( values . length === capacity ) { return values ; } } } return values ; } return [ ] ; }