Merge pull request #536 from ethereum/fixSteppingBack

fix findClosestIndex
pull/7/head
yann300 7 years ago committed by GitHub
commit 94d6049f11
  1. 4
      src/helpers/util.js

@ -99,9 +99,9 @@ module.exports = {
} }
var index = this.findLowerBound(target, array) var index = this.findLowerBound(target, array)
if (index < 0) { if (index < 0) {
return array[0] return 0
} else if (index >= array.length - 1) { } else if (index >= array.length - 1) {
return array[array.length - 1] return array.length - 1
} else { } else {
var middle = (array[index] + array[index + 1]) / 2 var middle = (array[index] + array[index + 1]) / 2
return target <= middle ? index : index + 1 return target <= middle ? index : index + 1

Loading…
Cancel
Save