Comparing version 1.4.0 to 1.4.1
{ | ||
"name": "heap-js", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Heap data structure for JavaScript / TypeScript.", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"engines": { | ||
"node": ">=6.0.0" | ||
"node": ">=10.0.0" | ||
}, | ||
@@ -83,3 +83,2 @@ "scripts": { | ||
"@types/node": "^12.7.2", | ||
"commitizen": "^4.0.3", | ||
"coveralls": "^3.0.6", | ||
@@ -86,0 +85,0 @@ "cross-env": "^5.2.0", |
128
README.md
@@ -1,3 +0,2 @@ | ||
![Heap.js](assets/heap-js.png) Heap.js | ||
====================================== | ||
# ![Heap.js](assets/heap-js.png) Heap.js | ||
@@ -10,3 +9,3 @@ [![Build Status](https://travis-ci.org/ignlg/heap-js.svg?branch=master)](https://travis-ci.org/ignlg/heap-js) | ||
**Heap data structure for JavaScript.** | ||
**Heap data structure for JavaScript and TypeScript.** | ||
@@ -17,4 +16,4 @@ Easy to use, known interfaces, tested, and well documented JavaScript binary heap library. | ||
Examples | ||
-------------- | ||
## Examples | ||
```js | ||
@@ -52,3 +51,3 @@ // Basic usage example | ||
import { Heap } from 'heap-js'; | ||
const numbers = [ 2, 3, 7, 5 ]; | ||
const numbers = [2, 3, 7, 5]; | ||
@@ -62,4 +61,4 @@ Heap.heapify(numbers); | ||
Installation | ||
------------ | ||
## Installation | ||
```bash | ||
@@ -71,74 +70,77 @@ yarn add heap-js # if you use yarn | ||
Constructor | ||
----------- | ||
## Constructor | ||
```js | ||
new Heap([comparator]) | ||
new Heap([comparator]); | ||
``` | ||
Basic comparators already included: | ||
* `Heap.minComparator` Integer min heap _(default)_ | ||
* `Heap.maxComparator` Integer max heap | ||
Implements JavaScript style methods | ||
----------------------------------- | ||
* `length` of the heap | ||
* `limit` amount of elements in the heap | ||
* `pop()` the top element | ||
* `push(...elements)` one or more elements to the heap | ||
* `pushpop(element)` faster than `push` & `pop` | ||
* `replace(element)` faster than `pop` & `push` | ||
* `top(number?)` most valuable elements from the heap | ||
* `bottom(number?)` least valuable elements from the heap | ||
- `Heap.minComparator` Integer min heap _(default)_ | ||
- `Heap.maxComparator` Integer max heap | ||
Implements Java's `PriorityQueue` interface: | ||
-------------------------------------------- | ||
* `add(element)` to the heap | ||
* `addAll([elment, element, ... ])` to the heap, faster than loop `add` | ||
* `clear()` | ||
* `clone()` | ||
* `comparator()` | ||
* `contains(element, fn?)` | ||
* _`element()` alias of `peek()`_ | ||
* `isEmpty()` | ||
* _`offer(element)` alias of `add(element)`_ | ||
* `peek()` | ||
* _`poll()` alias of `pop()`_ | ||
* `remove(element?)` | ||
* _`removeAll()` alias of `clear()`_ | ||
* _`size()` alias of `length`_ | ||
* `toArray()` | ||
* `toString()` | ||
## Implements JavaScript style methods | ||
- `length` of the heap | ||
- `limit` amount of elements in the heap | ||
- `pop()` the top element | ||
- `push(...elements)` one or more elements to the heap | ||
- `pushpop(element)` faster than `push` & `pop` | ||
- `replace(element)` faster than `pop` & `push` | ||
- `top(number?)` most valuable elements from the heap | ||
- `bottom(number?)` least valuable elements from the heap | ||
## Implements Java's `PriorityQueue` interface: | ||
- `add(element)` to the heap | ||
- `addAll([elment, element, ... ])` to the heap, faster than loop `add` | ||
- `clear()` | ||
- `clone()` | ||
- `comparator()` | ||
- `contains(element, fn?)` | ||
- _`element()` alias of `peek()`_ | ||
- `isEmpty()` | ||
- _`offer(element)` alias of `add(element)`_ | ||
- `peek()` | ||
- _`poll()` alias of `pop()`_ | ||
- `remove(element?)` | ||
- _`removeAll()` alias of `clear()`_ | ||
- _`size()` alias of `length`_ | ||
- `toArray()` | ||
- `toString()` | ||
To do: | ||
* `containsAll` | ||
* `equals` | ||
* `iterator()` | ||
* `retainAll` | ||
Implements static Python's `heapq` interface: | ||
--------------------------------------------- | ||
* `Heap.heapify(array, comparator?)` that converts an array to an array-heap | ||
* `Heap.heappop(heapArray, comparator?)` that takes the peek of the array-heap | ||
* `Heap.heappush(heapArray, item, comparator?)` that appends elements to the array-heap | ||
* `Heap.heappushpop(heapArray, item, comparator?)` faster than `heappush` & `heappop` | ||
* `Heap.heapreplace(heapArray, item, comparator?)` faster than `heappop` & `heappush` | ||
- `containsAll` | ||
- `equals` | ||
- `iterator()` | ||
- `retainAll` | ||
## Implements static Python's `heapq` interface: | ||
- `Heap.heapify(array, comparator?)` that converts an array to an array-heap | ||
- `Heap.heappop(heapArray, comparator?)` that takes the peek of the array-heap | ||
- `Heap.heappush(heapArray, item, comparator?)` that appends elements to the array-heap | ||
- `Heap.heappushpop(heapArray, item, comparator?)` faster than `heappush` & `heappop` | ||
- `Heap.heapreplace(heapArray, item, comparator?)` faster than `heappop` & `heappush` | ||
Extras: | ||
* `Heap.heaptop(n, heapArray, comparator?)` that returns the `n` most valuable elements of the array-heap | ||
* `Heap.heapbottom(n, heapArray, comparator?)` that returns the `n` least valuable elements of the array-heap | ||
- `Heap.heaptop(n, heapArray, comparator?)` that returns the `n` most valuable elements of the array-heap | ||
- `Heap.heapbottom(n, heapArray, comparator?)` that returns the `n` least valuable elements of the array-heap | ||
To do: | ||
* `merge(...iterables, comparator?)` | ||
* `nlargest(n, iterable, comparator?)` | ||
* `nsmallest(n, iterable, comparator?)` | ||
Documentation | ||
------------- | ||
- `merge(...iterables, comparator?)` | ||
- `nlargest(n, iterable, comparator?)` | ||
- `nsmallest(n, iterable, comparator?)` | ||
## Documentation | ||
Extensive documentation included at `./dist/docs`. It'll be published to `gh-pages` in a next release. | ||
Contributing | ||
------------ | ||
## Contributing | ||
Development of **Heap.js** happens in the open on GitHub, and I am grateful to the community for contributing bugfixes and improvements. | ||
### Dev setup | ||
@@ -162,2 +164,2 @@ | ||
Heap.js is [BSD licensed](LICENSE). | ||
Heap.js is [BSD licensed](LICENSE). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24
160
2069519