Skip to content

Commit

Permalink
feat: binary search (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
simboonlong authored Mar 3, 2023
1 parent 941dcd0 commit e03870a
Show file tree
Hide file tree
Showing 7 changed files with 12,619 additions and 21,109 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![CI](https://github.com/simboonlong/utility/workflows/CI/badge.svg?branch=master&event=push) [![Netlify Status](https://api.netlify.com/api/v1/badges/0c993cb8-5cca-4c05-a543-a921ff62dee0/deploy-status)](https://app.netlify.com/sites/simboonlong-utility/deploys)

![Statements](https://img.shields.io/badge/statements-97.32%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-94.02%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-96.42%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-96.85%25-brightgreen.svg?style=flat)
![Statements](https://img.shields.io/badge/statements-97.61%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-94.87%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-96.55%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-97.23%25-brightgreen.svg?style=flat)

# Utility

Expand Down Expand Up @@ -333,6 +333,32 @@ const foo = async () => {

---

#### binarySearch

Binary search on array.

```
import { binarySearch } from "@simboonlong/utility"
const index = binarySearch([0, 1, 2, 3], 1);
// index returns 1, then do something with index
```

---

#### binarySearchClosest

Binary search closest value on array.

```
import { binarySearchClosest } from "@simboonlong/utility"
const index = binarySearchClosest([0, 1, 2, 3], 1.2);
// index returns 1, then do something with index
```

---

#### inlineAttribute

Apply inline attributes from object.
Expand Down
Loading

0 comments on commit e03870a

Please sign in to comment.