artdaq_node_server  v1_00_09
 All Classes Namespaces Files Variables Pages
_baseSortedIndex.js
1 var baseSortedIndexBy = require('./_baseSortedIndexBy'),
2  identity = require('./identity'),
3  isSymbol = require('./isSymbol');
4 
6 var MAX_ARRAY_LENGTH = 4294967295,
7  HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
8 
21 function baseSortedIndex(array, value, retHighest) {
22  var low = 0,
23  high = array == null ? low : array.length;
24 
25  if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
26  while (low < high) {
27  var mid = (low + high) >>> 1,
28  computed = array[mid];
29 
30  if (computed !== null && !isSymbol(computed) &&
31  (retHighest ? (computed <= value) : (computed < value))) {
32  low = mid + 1;
33  } else {
34  high = mid;
35  }
36  }
37  return high;
38  }
39  return baseSortedIndexBy(array, value, identity, retHighest);
40 }
41 
42 module.exports = baseSortedIndex;