export default { param array param compareFunction getBinaryInsertIndex : function < T > ( array , compareFunction ) : { index : number ; itemExists : boolean ; } { let low = 0 ; let high = array . length - 1 ; while ( low <= high ) { let middle = low + Math . floor ( ( high - low ) / 2 ) ; let comparison = compareFunction ( array [ middle ] ) ; if ( comparison < 0 ) { low = middle + 1 ; } else if ( comparison > 0 ) { high = middle - 1 ; } else { return { index : middle , itemExists : true } ; } } return { index : low , itemExists : false } ; } , /**
     * Gets an element or undefined if the element does not exist
     */ at : function < T > ( array , index ) { let n = Math . trunc ( index ) || 0 ; if ( n < 0 ) n += array . length ; if ( n < 0 || n >= array . length ) return undefined ; return array [ n ] ; } , /**
     * Removes an element from an array
     */ remove : function < T > ( array , element ) { const index = array . indexOf ( element ) ; if ( index >= 0 ) { array . splice ( index , 1 ) ; return true ; } else { return false ; } } , } ;