@extra-array/bsearchl
@extra-array/bsearchl
npm i @extra-array/bsearchl
@extra-array/bsearchl

@extra-array/bsearchl

An array is a collection of values, stored contiguously.

by nodef

2.1.75 (see all)License:MITTypeScript:Not Found
npm i @extra-array/bsearchl
Readme

Binary searches leftmost value in sorted array.

Alternatives: default, closest, left, right.
This is part of package extra-array.

array.bsearchl(x, v, [fn]);
// x:  an array (sorted)
// v:  value to find
// fn: compare function (a, b)
// --> first index of value | ~(index of closest value)
const array = require('extra-array');

array.bsearchl([1, 3, 5, 7], 5);
// 2                  ^ found

array.bsearchl([1, 3, 5, 7], 4);
// -3 (~2)            ^ not found, closest

array.bsearchl([4, 4, 4, 4], 4);
// 0            ^ leftmost

array.bsearchl(['b', 'GB', 'KB', 'MB'], 'kB', (a, b) => {
  return a.toLowerCase().localeCompare(b.toLowerCase());
});
// 2                        ^ case insensitive

references

Downloads/wk

122

GitHub Stars

14

LAST COMMIT

7mos ago

MAINTAINERS

1

CONTRIBUTORS

3

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
2.1.75
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate