# binaryheap

> A simple binary heap

Latest version **0.0.3** (published 2013-03-24) · 0 weekly downloads

## Install

```sh
npm install binaryheap
pnpm add binaryheap
yarn add binaryheap
bun add binaryheap
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2013-03-24 |
| First published | 2012-09-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Timothy J Fontaine |
| Maintainers | tjfontaine |
| Keywords | balanced, binary, heap, minheap, maxheap |

## Links

- npm: https://www.npmjs.com/package/binaryheap
- Repository: http://github.com/tjfontaine/node-binaryheap
- Issues: http://github.com/tjfontaine/node-binaryheap/issues
- npm.io page: https://npm.io/package/binaryheap

## Recent versions

- 0.0.3 (latest) — 2013-03-24
- 0.0.2 — 2012-12-28
- 0.0.1 — 2012-09-19

## README

BinaryHeap
==========

Basic binary heap tree using linked lists

Usage
-----

```javascript
var BinaryHeap = require('binaryheap');
var heap = new BinaryHeap();

var a = [6, 5, 3, 1, 8, 7, 2, 4];

a.forEach(function (k) {
  heap.insert({ value: k }, k);
});

heap.print();

while (heap.length) {
  console.log('popping', heap.pop().value);
}
```

By default it stores as a max-heap, if you pass truthy to the constructor though
it will behave as a min-heap.

Methods
-------

 * `insert(obj, key)` -- obj can be any new or existing object, and key is any
value that behaves sanely with `>` or `<`
 * `pop()` -- removes and returns the maximum or minimum object from the root
of the heap
 * `remove(obj)` -- removes a previously inserted object from the heap
 * `print()` -- mostly for debugging purposes prints a graphviz dot style
digraph to confirm ordering

Members
-------

 * `length` -- number of objects currently in the heap

---
_Source: https://npm.io/package/binaryheap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
