0.0.3 • Published 12 years ago
lower-bound v0.0.3
lower-bound
Finds the first item in a sorted array less than or equal to a value.
Use
First install using npm:
npm install lower-boundThen use as follows:
var lb = require("lower-bound")
console.log(lb([0, 1, 1, 1, 2], 1)) // Prints 1
console.log(lb([0, 1, 1, 1, 2], 1.5)) // Prints 3require("lower-bound")(array, value[, compare, lo, hi])
Uses a binary search to find the first item which is <= to value in array.
arraya sorted list of itemsvaluethe item to findcomparea comparison function (optional)loa lower bound to search on (optional)hian upper bound on the range to search on (optional)
Credits
(c) 2013 Mikola Lysenko. MIT License