New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

binary-search-range

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-search-range

Use binary search to find a range of matching elements

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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

Keywords

binary

FAQs

Package last updated on 31 May 2017

Related posts