docs: function findClosestIntervalInSortedIntervals(ary, mapLoFn, mapHiFn, val,
                                                  maxDiff) {
      if (ary.length === 0)
        return null;
  
      var idx = findLowIndexInSortedArray(ary, mapLoFn, val);
      if (idx > 0)
        idx -= 1;
  
      var hiInt = ary[idx];
      var loInt = hiInt;
  
      if (val > mapHiFn(hiInt) && idx + 1 < ary.length)
        loInt = ary[idx + 1];
  
      var loDiff = Math.abs(val - mapLoFn(loInt));
      var hiDiff = Math.abs(val - mapHiFn(hiInt));
  
      if (loDiff > maxDiff && hiDiff > maxDiff)
        return null;
  
      if (loDiff < hiDiff)
        return loInt;
      else
        return hiInt;
    }