| @@ 4108-4127 (lines=20) @@ | ||
| 4105 | * @returns {number} Returns the index at which `value` should be inserted |
|
| 4106 | * into `array`. |
|
| 4107 | */ |
|
| 4108 | function baseSortedIndex(array, value, retHighest) { |
|
| 4109 | var low = 0, |
|
| 4110 | high = array == null ? low : array.length; |
|
| 4111 | ||
| 4112 | if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { |
|
| 4113 | while (low < high) { |
|
| 4114 | var mid = (low + high) >>> 1, |
|
| 4115 | computed = array[mid]; |
|
| 4116 | ||
| 4117 | if (computed !== null && !isSymbol(computed) && |
|
| 4118 | (retHighest ? (computed <= value) : (computed < value))) { |
|
| 4119 | low = mid + 1; |
|
| 4120 | } else { |
|
| 4121 | high = mid; |
|
| 4122 | } |
|
| 4123 | } |
|
| 4124 | return high; |
|
| 4125 | } |
|
| 4126 | return baseSortedIndexBy(array, value, identity, retHighest); |
|
| 4127 | } |
|
| 4128 | ||
| 4129 | /** |
|
| 4130 | * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` |
|
| @@ 21-40 (lines=20) @@ | ||
| 18 | * @returns {number} Returns the index at which `value` should be inserted |
|
| 19 | * into `array`. |
|
| 20 | */ |
|
| 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 | export default baseSortedIndex; |
|
| 43 | ||
| @@ 21-40 (lines=20) @@ | ||
| 18 | * @returns {number} Returns the index at which `value` should be inserted |
|
| 19 | * into `array`. |
|
| 20 | */ |
|
| 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; |
|
| 43 | ||