# functionalpriorityqueue

> A functional implementation of a bheap

Latest version **1.0.1** (published 2017-03-14) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-03-14 |
| First published | 2017-03-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | wi-ski |
| Maintainers | wiski |
| Keywords | functional, javascript, bheap, priority, queue, = |

## Links

- npm: https://www.npmjs.com/package/functionalpriorityqueue
- Repository: https://github.com/wi-ski/FunctionalPriorityQueue
- Homepage: https://github.com/wi-ski/FunctionalPriorityQueue#readme
- Issues: https://github.com/wi-ski/FunctionalPriorityQueue/issues
- npm.io page: https://npm.io/package/functionalpriorityqueue

## Dependencies (1)

- [ava](https://npm.io/package/ava.md) ^0.18.2

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-03-14
- 1.0.0 — 2017-03-14

## README

#A functional heap-based priority queue utility written in Javascript

This is a heap that I built for a recent set of interviews and thought they might come in handy for someone in the future.
I've been trying to get my mind in the habit of thinking more functionally and this was a fun discipline project.
I don't believe this a great a example of what I consider functional programming, however - it exhibits how I chose to approach the problem within a budgeted amount of time.

Usage
===

```javascript
const shouldSwap = (child, parent) => (parent > child); //min
const {heapPop,heapPush} = heapFactory(shouldSwap);

const heap = [];
const heap0 = heapPush(heap,0)
const heap1 = heapPush(heap0,1)
const heap2 = heapPush(heap1,2)
const heap3 = heapPush(heap2,3)
const heap4 = heapPush(heap3,4)
const heap5 = heapPush(heap4,5)

const [nextHeap,poppedValue] = heapPop(heap5); //returns [ [ 1, 3, 2, 5, 4 ], 0 ]
```

You can provide a comparator to the erroneously named `heapFactory`. It defaults to:`(child, parent) => (parent > child);`

#Running
```
npm install functionalpriorityqueue
```
and
```
npm install
```
and
```
npm test
```

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