0.1.8 • Published 6 years ago

array-binarysearch.comparator v0.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

array-binarysearch.comparator

NPM

Get index of value in sorted (using comparator).

DEPRECATED: Please use array-binarysearch instead.

const binarySearch = require('array-binarysearch.comparator');
// binarySearch(<array>, <value>, <compare function>, [this], [begin=0], [end=array.length])

binarySearch([21, 42, 91, 91], 42, (a, b) => a===b? 0:(a<b? -1:1));
// 1
binarySearch(['G', 'KG', 'KG', 'MG'], 'g', (a, b, i) => a.toLowerCase().localeCompare(b.toLowerCase()), null, 1);
// -2 (-ve => not found, closest: ~(-2) = 1)
binarySearch(['G', 'KG', 'KG', 'MG'], 'KG', (a, b, i, arr) => a.localeCompare(b), null, 1, 4);
// 2
0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago