mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Make baseSortedIndex handle NaN correctly when comparing numbers.
This commit is contained in:
@@ -2400,10 +2400,16 @@
|
|||||||
high = array ? array.length : low;
|
high = array ? array.length : low;
|
||||||
|
|
||||||
value = iterator(value);
|
value = iterator(value);
|
||||||
|
var hintNum = typeof value == 'number' ||
|
||||||
|
(value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number');
|
||||||
|
|
||||||
while (low < high) {
|
while (low < high) {
|
||||||
var mid = (low + high) >>> 1,
|
var mid = (low + high) >>> 1,
|
||||||
computed = iterator(array[mid]);
|
computed = iterator(array[mid]);
|
||||||
|
|
||||||
|
if (hintNum && typeof computed != 'undefined') {
|
||||||
|
computed = +computed || 0;
|
||||||
|
}
|
||||||
if (retHighest ? computed <= value : computed < value) {
|
if (retHighest ? computed <= value : computed < value) {
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user