Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amaui-org/amaui-heap
Min/Max Heap
https://github.com/amaui-org/amaui-heap
algorithm amaui back-end backend binary-search-tree binary-tree browser front-end frontend heap javascript js max-heap min-heap node nodejs priority-queue typescript utils web
Last synced: 7 days ago
JSON representation
Min/Max Heap
- Host: GitHub
- URL: https://github.com/amaui-org/amaui-heap
- Owner: amaui-org
- License: mit
- Created: 2022-02-13T18:28:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-29T22:27:19.000Z (8 months ago)
- Last Synced: 2024-10-03T07:19:29.514Z (about 1 month ago)
- Topics: algorithm, amaui, back-end, backend, binary-search-tree, binary-tree, browser, front-end, frontend, heap, javascript, js, max-heap, min-heap, node, nodejs, priority-queue, typescript, utils, web
- Language: TypeScript
- Homepage: https://docs.amaui.me/library/heap
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
amaui Heap
Min/Max Heap
MIT license
Production ready
UMD 2kb gzipped
100% test cov
Browser and Nodejs
Very simple code
Modern code
Junior friendly
Typescript
Made with :yellow_heart:
## Getting started
### Add
```sh
yarn add @amaui/heap
```### Use cases
- Priority queues
- Schedulers
- etc.### Use
```javascript
import { AmauiHeap } from '@amaui/heap';// Make a new heap instance
// with an optional initial value a variant (min or max)
// a min heap as a default value
const amauiMinHeap = new AmauiHeap();// Add a amaui node / value
amauiMinHeap.add(4);// You can also make a heap from array of values
amauiMinHeap.make([4, 44, 54, 14, 31, 37, 24]);// values
4
/ \
/ \
14 24
/ \ / \
44 31 37 54// Remove priority min (first) value
amauiMinHeap.remove();// 4
// values
14
/ \
/ \
31 24
/ \ /
44 54 37
```### Dev
Install
```sh
yarn
```Test
```sh
yarn test
```### Prod
Build
```sh
yarn build
```