export class UtilityHelper { public constructor ( ) { } public groupBy ( xs , key ) { return xs . reduce ( ( rv , x ) => { ( rv [ x [ key ] ] = rv [ x [ key ] ] || [ ] ) . push ( x ) ; return rv ; } , { } ) ; } public removeElementsFromArrayWithoutModifyingIt ( elements ? , elementsToRemove ? ) { if ( elements === undefined ) { return [ ] ; } if ( Array . isArray ( elementsToRemove ) ) { return elements . filter ( element => { if ( typeof element === "object" ) { const key = Object . keys ( element ) [ 0 ] ; return ! elementsToRemove . some ( x => key in x ) ; } return elementsToRemove . indexOf ( element ) < 0 ; } ) ; } else { return elements . filter ( element => { return elementsToRemove !== element ; } ) ; } } }