Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Commit

Permalink
Deprecate module, moved to Deno's standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleJune committed Apr 2, 2022
1 parent ccceae0 commit f432a67
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Collections

[![version](https://img.shields.io/badge/release-0.12.0-success)](https://github.com/udibo/collections/tree/0.12.0)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/collections@0.12.0/mod.ts)
[![version](https://img.shields.io/badge/release-0.12.1-success)](https://github.com/udibo/collections/tree/0.12.1)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/collections@0.12.1/mod.ts)
[![CI](https://github.com/udibo/collections/workflows/CI/badge.svg)](https://github.com/udibo/collections/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/udibo/collections/branch/main/graph/badge.svg?token=JYYBU68VCT)](https://codecov.io/gh/udibo/collections)
[![license](https://img.shields.io/github/license/udibo/collections)](https://github.com/udibo/collections/blob/master/LICENSE)

Collection classes that are not standard built-in objects in JavaScript. This
includes a vector, binary heap, binary search tree, and a red-black tree.

This module is being archived. BinaryHeap, BSTree, and RBTree have been added to
Deno's standard library in the collections directory. Use Deno's standard
library instead.

## Installation

This is an ES Module written in TypeScript and can be used in Deno projects. ES
Expand All @@ -24,19 +28,19 @@ imported directly from GitHub using raw content URLs.

```ts
// Import from Deno's third party module registry
import { Vector } from "https://deno.land/x/collections@0.12.0/mod.ts";
import { Vector } from "https://deno.land/x/collections@0.12.1/mod.ts";
// Import from GitHub
import { Vector } "https://raw.githubusercontent.com/udibo/collections/0.12.0/mod.ts";
import { Vector } "https://raw.githubusercontent.com/udibo/collections/0.12.1/mod.ts";
```
If you do not need all of the sub-modules, you can choose to just import the
sub-modules you need.
```ts
// Import from Deno's third party module registry
import { Vector } from "https://deno.land/x/collections@0.12.0/vector.ts";
import { Vector } from "https://deno.land/x/collections@0.12.1/vector.ts";
// Import from GitHub
import { Vector } from "https://raw.githubusercontent.com/udibo/collections/0.12.0/vector.ts";
import { Vector } from "https://raw.githubusercontent.com/udibo/collections/0.12.1/vector.ts";
```

### Node.js
Expand All @@ -47,15 +51,15 @@ If a Node.js package has the type "module" specified in its package.json file,
the JavaScript bundle can be imported as a `.js` file.

```js
import { Vector } from "./collections_0.12.0.js";
import { Vector } from "./collections_0.12.1.js";
```

The default type for Node.js packages is "commonjs". To import the bundle into a
commonjs package, the file extension of the JavaScript bundle must be changed
from `.js` to `.mjs`.

```js
import { Vector } from "./collections_0.12.0.mjs";
import { Vector } from "./collections_0.12.1.mjs";
```

See [Node.js Documentation](https://nodejs.org/api/esm.html) for more
Expand All @@ -74,15 +78,15 @@ modules must have the type attribute set to "module".

```js
// main.js
import { Vector } from "./collections_0.12.0.js";
import { Vector } from "./collections_0.12.1.js";
```

You can also embed a module script directly into an HTML file by placing the
JavaScript code within the body of the script tag.

```html
<script type="module">
import { Vector } from "./collections_0.12.0.js";
import { Vector } from "./collections_0.12.1.js";
</script>
```

Expand All @@ -99,7 +103,7 @@ than JavaScript's built in Array class for unshifting and shifting because it
only requires reallocation when increasing the capacity.

See
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.0/mod.ts#Vector)
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.1/mod.ts#Vector)
for more information.

### BinaryHeap
Expand All @@ -108,7 +112,7 @@ A priority queue implemented with a binary heap. The heap is in decending order
by default, using JavaScript's built in comparison operators to sort the values.

See
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.0/mod.ts#BinaryHeap)
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.1/mod.ts#BinaryHeap)
for more information.

#### BinaryHeap Efficiency
Expand All @@ -127,7 +131,7 @@ Creating and using max and min heaps:
import {
ascend,
BinaryHeap,
} from "https://deno.land/x/collections@0.12.0/mod.ts";
} from "https://deno.land/x/collections@0.12.1/mod.ts";

const maxHeap: BinaryHeap<number> = new BinaryHeap();
maxHeap.push(...[4, 1, 3, 6, 2]); // 5
Expand All @@ -150,7 +154,7 @@ An unbalanced binary search tree. The values are in ascending order by default,
using JavaScript's built in comparison operators to sort the values.

See
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.0/mod.ts#BSTree)
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.1/mod.ts#BSTree)
for more information.

#### BSTree Efficiency
Expand All @@ -175,7 +179,7 @@ A red-black tree. The values are in ascending order by default, using
JavaScript's built in comparison operators to sort the values.

See
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.0/mod.ts#RBTree)
[deno docs](https://doc.deno.land/https/deno.land/x/collections@0.12.1/mod.ts#RBTree)
for more information.

#### RBTree Efficiency
Expand Down
2 changes: 2 additions & 0 deletions binary_heap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { descend } from "./comparators.ts";
/**
* A priority queue implemented with a binary heap. The heap is in decending order by default,
* using JavaScript's built in comparison operators to sort the values.
*
* @deprecated Use https://deno.land/std/collections/binary_heap.ts instead.
*/
export class BinaryHeap<T> implements Iterable<T> {
private data: T[] = [];
Expand Down
2 changes: 2 additions & 0 deletions trees/bs_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { BSNode, direction } from "./bs_node.ts";
/**
* A unbalanced binary search tree. The values are in ascending order by default,
* using JavaScript's built in comparison operators to sort the values.
*
* @deprecated Use https://deno.land/std/collections/bs_tree.ts instead
*/
export class BSTree<T> implements Iterable<T> {
protected root: BSNode<T> | null = null;
Expand Down
2 changes: 2 additions & 0 deletions trees/rb_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { direction, RBNode } from "./rb_node.ts";
/**
* A red-black tree. The values are in ascending order by default,
* using JavaScript's built in comparison operators to sort the values.
*
* @deprecated Use https://deno.land/std/collections/rb_tree.ts instead
*/
export class RBTree<T> extends BSTree<T> {
declare protected root: RBNode<T> | null;
Expand Down
2 changes: 2 additions & 0 deletions vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function reduce<T, U>(
* A double-ended queue implemented with a growable ring buffer.
* Vector is faster than JavaScript's built in Array class for shifting and unshifting
* because it only requires reallocation when increasing the capacity.
*
* @deprecated Use Array instead. Arrays are generally faster for all other operations besides shifting and unshifting.
*/
export class Vector<T> implements Iterable<T> {
private data: (T | undefined)[];
Expand Down

0 comments on commit f432a67

Please sign in to comment.