binary-search-range

1.0.1 • Public • Published

binary-search-range

NPM

Built on binary-search. Returns all indexes of items that match the comparator.

const haystack = [ 1, 3, 5, 6, 6, 6, 9, 11, 14 ]
const needle = 6
const comparator = (a, b) => a - b
binarySearchRange(haystack, needle, comparator) // => [ 3, 4, 5 ]

binarySearchRange(haystack, needle, comparator, lowIndex, highIndex)

comparator should be a function that returns 0 for matches, just like your sort function.

License

WTFPL

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    2
  • 1.0.0
    1

Package Sidebar

Install

npm i binary-search-range

Weekly Downloads

2

Version

1.0.1

License

WTFPL

Last publish

Collaborators

  • tehshrike