/**
 * Searches the specified array of doubles for the specified value using
 * the binary search algorithm.  The array must be sorted
 * (as by the  {@link #sort(double[])} method) prior to making this call.
 * If it is not sorted, the results are undefined.  If the array contains
 * multiple elements with the specified value, there is no guarantee which
 * one will be found.  This method considers all NaN values to be
 * equivalent and equal.
 *
 *  param a param key return export function binarySearch ( a , key ) { let fromIndex = 0 ; let toIndex = a . length ; let low = fromIndex ; let high = toIndex - 1 ; while ( low <= high ) { let mid = ( low + high ) >>> 1 ; let midVal = a [ mid ] ; if ( midVal < key ) { low = mid + 1 ; } else if ( midVal > key ) { high = mid - 1 ; } else { return mid ; } } return - ( low + 1 ) ; }