https://github.com/olical/binary-search
Binary search implementation in JavaScript born from a couple of my blog posts
https://github.com/olical/binary-search
Last synced: 9 months ago
JSON representation
Binary search implementation in JavaScript born from a couple of my blog posts
- Host: GitHub
- URL: https://github.com/olical/binary-search
- Owner: Olical
- License: unlicense
- Created: 2014-12-17T23:30:20.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-01-18T16:33:33.000Z (over 10 years ago)
- Last Synced: 2025-04-14T08:53:26.732Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://oli.me.uk/2014/12/17/revisiting-searching-javascript-arrays-with-a-binary-search/
- Size: 5.86 KB
- Stars: 25
- Watchers: 3
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# binary-search
This is a binary search implementation in JavaScript that was born from a couple of [my blog posts][posts]. It focusses on heavy generative testing and benchmarks to make sure it works and runs fast.
## Usage
Install the package, `olical-binary-search`, and use it like this.
```javascript
import binarySearch from 'olical-binary-search'
const items = [10, 20, 30, 40, 50]
binarySearch(items, 30) // Yields: 2
binarySearch(items, 100) // Yields: -1
```
## License
This repository is released under [the unlicense][], feel free to do whatever you want. You can find the full license within the `UNLICENSE` file.
>This is free and unencumbered software released into the public domain.
>
>Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
[the unlicense]: http://unlicense.org/
[posts]: http://oli.me.uk/2014/12/17/revisiting-searching-javascript-arrays-with-a-binary-search/