diff --git a/.github/codecov.yml b/.github/codecov.yml
new file mode 100644
index 0000000..98fa4e5
--- /dev/null
+++ b/.github/codecov.yml
@@ -0,0 +1,10 @@
+comment: false
+codecov:
+ require_ci_to_pass: true
+coverage:
+ status:
+ project:
+ default:
+ informational: true
+ignore:
+ - examples
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 96194c9..9cd152b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,61 +2,54 @@ name: CI
on: [push, pull_request]
jobs:
build:
- name: ${{ matrix.config.kind }} ${{ matrix.config.os }}
- runs-on: ${{ matrix.config.os }}
+ name: test deno ${{ matrix.deno }} ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
matrix:
- config:
- - os: macOS-latest
- kind: test
- - os: windows-latest
- kind: test
- - os: ubuntu-latest
- kind: test
- - os: ubuntu-latest
- kind: bench
- - os: ubuntu-latest
- kind: lint
+ os: [ubuntu-latest, windows-latest, macOS-latest]
+ deno: [v1.x, canary]
+ fail-fast: true
steps:
- name: Clone repository
uses: actions/checkout@v2
- - name: Install deno
- uses: denolib/setup-deno@master
+ - name: Setup deno
+ uses: denoland/setup-deno@main
with:
- deno-version: 1.9.0
+ deno-version: ${{ matrix.deno }}
- name: Check formatting
- if: matrix.config.kind == 'lint'
- run: |
- deno fmt --check
- deno lint --unstable
- - name: Benchmark
- if: matrix.config.kind == 'bench'
- run: deno run bench.ts
- - name: Test
- if: matrix.config.kind == 'test'
- run: |
- deno test
- - name: Test unstable
- if: matrix.config.kind == 'test'
- run: |
- deno test --coverage=cov_profile --unstable
- - name: Test coverage
- if: matrix.config.kind == 'test'
- run: |
- deno coverage --unstable cov_profile
+ if: matrix.os == 'ubuntu-latest'
+ run: deno fmt --check
+ - name: Check linting
+ if: matrix.os == 'ubuntu-latest'
+ run: deno lint
+ - name: Run tests
+ run: deno test --coverage=cov
+ - name: Run tests unstable
+ run: deno test --unstable
+ - name: Generate lcov
+ if: |
+ matrix.os == 'ubuntu-latest' &&
+ matrix.deno == 'v1.x'
+ run: deno coverage --lcov cov > cov.lcov
+ - name: Upload coverage
+ if: |
+ matrix.os == 'ubuntu-latest' &&
+ matrix.deno == 'v1.x'
+ uses: codecov/codecov-action@v1
+ with:
+ files: cov.lcov
- name: Release info
if: |
- matrix.config.kind == 'test' &&
github.repository == 'udibo/collections' &&
+ matrix.os == 'ubuntu-latest' &&
+ matrix.deno == 'v1.x' &&
startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Bundle
- if: |
- env.RELEASE_VERSION != '' &&
- startsWith(matrix.config.os, 'ubuntu')
+ if: env.RELEASE_VERSION != ''
run: |
mkdir -p target/release
deno bundle mod.ts target/release/collections_${RELEASE_VERSION}.js
diff --git a/README.md b/README.md
index ebfee41..503be06 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,13 @@
# Collections
-[![version](https://img.shields.io/badge/release-v0.11.0-success)](https://github.com/udibo/collections/tree/v0.11.0)
-[![deno doc](https://img.shields.io/badge/deno-doc-success?logo=deno)](https://doc.deno.land/https/deno.land/x/collections@v0.11.0/mod.ts)
-[![deno version](https://img.shields.io/badge/deno-v1.9.0-success?logo=deno)](https://github.com/denoland/deno/tree/v1.9.0)
+[![version](https://img.shields.io/badge/release-v0.11.1-success)](https://github.com/udibo/collections/tree/v0.11.1)
+[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/collections@v0.11.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/master/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)
-This module provides implementations of collection objects that are not standard
-built-in objects in JavaScript.
+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.
## Installation
@@ -24,9 +24,9 @@ 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@v0.11.0/mod.ts";
+import { Vector } from "https://deno.land/x/collections@v0.11.1/mod.ts";
// Import from GitHub
-import { Vector } "https://raw.githubusercontent.com/udibo/collections/v0.11.0/mod.ts";
+import { Vector } "https://raw.githubusercontent.com/udibo/collections/v0.11.1/mod.ts";
```
If you do not need all of the sub-modules, you can choose to just import the
@@ -34,9 +34,9 @@ sub-modules you need.
```ts
// Import from Deno's third party module registry
-import { Vector } from "https://deno.land/x/collections@v0.11.0/vector.ts";
+import { Vector } from "https://deno.land/x/collections@v0.11.1/vector.ts";
// Import from GitHub
-import { Vector } from "https://raw.githubusercontent.com/udibo/collections/v0.11.0/vector.ts";
+import { Vector } from "https://raw.githubusercontent.com/udibo/collections/v0.11.1/vector.ts";
```
### Node.js
@@ -47,7 +47,7 @@ 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_v0.11.0.js";
+import { Vector } from "./collections_v0.11.1.js";
```
The default type for Node.js packages is "commonjs". To import the bundle into a
@@ -55,7 +55,7 @@ commonjs package, the file extension of the JavaScript bundle must be changed
from `.js` to `.mjs`.
```js
-import { Vector } from "./collections_v0.11.0.mjs";
+import { Vector } from "./collections_v0.11.1.mjs";
```
See [Node.js Documentation](https://nodejs.org/api/esm.html) for more
@@ -74,7 +74,7 @@ modules must have the type attribute set to "module".
```js
// main.js
-import { Vector } from "./collections_v0.11.0.js";
+import { Vector } from "./collections_v0.11.1.js";
```
You can also embed a module script directly into an HTML file by placing the
@@ -82,7 +82,7 @@ JavaScript code within the body of the script tag.
```html
```
@@ -99,7 +99,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@v0.11.0/mod.ts#Vector)
+[deno docs](https://doc.deno.land/https/deno.land/x/collections@v0.11.1/mod.ts#Vector)
for more information.
### BinaryHeap
@@ -108,7 +108,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@v0.11.0/mod.ts#BinaryHeap)
+[deno docs](https://doc.deno.land/https/deno.land/x/collections@v0.11.1/mod.ts#BinaryHeap)
for more information.
#### BinaryHeap Efficiency
@@ -124,8 +124,10 @@ for more information.
Creating and using max and min heaps:
```ts
-import { BinaryHeap } from "https://deno.land/x/collections@v0.11.0/binary_heap.ts";
-import { ascend } from "https://deno.land/x/collections@v0.11.0/comparators.ts";
+import {
+ ascend,
+ BinaryHeap,
+} from "https://deno.land/x/collections@v0.11.1/mod.ts";
const maxHeap: BinaryHeap = new BinaryHeap();
maxHeap.push(...[4, 1, 3, 6, 2]); // 5
@@ -134,7 +136,7 @@ maxHeap.pop(); // 6
maxHeap.peek(); // 4
maxHeap.pop(); // 4
-const minHeap: BinaryHeap = new BinaryHeap(ascend);
+const minHeap: BinaryHeap = new BinaryHeap(ascend);
minHeap.push(...[4, 5, 3, 6, 2]);
minHeap.peek(); // 2
minHeap.pop(); // 2
@@ -148,7 +150,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@v0.11.0/mod.ts#BSTree)
+[deno docs](https://doc.deno.land/https/deno.land/x/collections@v0.11.1/mod.ts#BSTree)
for more information.
#### BSTree Efficiency
@@ -173,7 +175,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@v0.11.0/mod.ts#RBTree)
+[deno docs](https://doc.deno.land/https/deno.land/x/collections@v0.11.1/mod.ts#RBTree)
for more information.
#### RBTree Efficiency
diff --git a/bench.ts b/bench.ts
index 1561e12..7486f61 100644
--- a/bench.ts
+++ b/bench.ts
@@ -1,4 +1,4 @@
-import { runBenchmarks } from "./deps/std/testing/bench.ts";
+import { runBenchmarks } from "./test_deps.ts";
import "./vector_bench.ts";
import "./trees/bench.ts";
diff --git a/binary_heap_test.ts b/binary_heap_test.ts
index 5c781b2..3b6e49b 100644
--- a/binary_heap_test.ts
+++ b/binary_heap_test.ts
@@ -1,7 +1,6 @@
-import { assertEquals } from "./deps/std/testing/asserts.ts";
-import { BinaryHeap } from "./binary_heap.ts";
-import { ascend, descend } from "./comparators.ts";
+import { assertEquals } from "./test_deps.ts";
import { Container, MyMath } from "./test_common.ts";
+import { ascend, BinaryHeap, descend } from "./mod.ts";
Deno.test("BinaryHeap with default descend comparator", () => {
const maxHeap: BinaryHeap = new BinaryHeap();
diff --git a/common_test.ts b/common_test.ts
index 0081ef4..d224755 100644
--- a/common_test.ts
+++ b/common_test.ts
@@ -3,10 +3,10 @@ import {
assertEquals,
assertStrictEquals,
assertThrows,
-} from "./deps/std/testing/asserts.ts";
-import { test, TestSuite } from "./deps/udibo/test_suite/mod.ts";
-import { ascend } from "./comparators.ts";
-import { count, range, shuffle, swap } from "./common.ts";
+ test,
+ TestSuite,
+} from "./test_deps.ts";
+import { ascend, count, range, shuffle, swap } from "./mod.ts";
const commonTests = new TestSuite({ name: "common" });
diff --git a/comparators_test.ts b/comparators_test.ts
index c22db42..93d0550 100644
--- a/comparators_test.ts
+++ b/comparators_test.ts
@@ -1,5 +1,5 @@
-import { assertEquals } from "./deps/std/testing/asserts.ts";
-import { ascend, descend } from "./comparators.ts";
+import { assertEquals } from "./test_deps.ts";
+import { ascend, descend } from "./mod.ts";
Deno.test("ascend", () => {
assertEquals(ascend(undefined, undefined), 0);
diff --git a/deps/std/testing/asserts.ts b/deps/std/testing/asserts.ts
deleted file mode 100644
index 0b4394d..0000000
--- a/deps/std/testing/asserts.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export {
- assert,
- assertEquals,
- assertStrictEquals,
- assertThrows,
-} from "https://deno.land/std@0.93.0/testing/asserts.ts";
diff --git a/deps/std/testing/bench.ts b/deps/std/testing/bench.ts
deleted file mode 100644
index f70400a..0000000
--- a/deps/std/testing/bench.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export {
- bench,
- runBenchmarks,
-} from "https://deno.land/std@0.93.0/testing/bench.ts";
-export type { BenchmarkTimer } from "https://deno.land/std@0.93.0/testing/bench.ts";
diff --git a/deps/udibo/test_suite/mod.ts b/deps/udibo/test_suite/mod.ts
deleted file mode 100644
index c1ff6ab..0000000
--- a/deps/udibo/test_suite/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { test, TestSuite } from "https://deno.land/x/test_suite@v0.6.4/mod.ts";
diff --git a/examples/binary_heap.ts b/examples/binary_heap.ts
index cb199a0..8f183c6 100644
--- a/examples/binary_heap.ts
+++ b/examples/binary_heap.ts
@@ -1,5 +1,4 @@
-import { BinaryHeap } from "../binary_heap.ts";
-import { ascend } from "../comparators.ts";
+import { ascend, BinaryHeap } from "../mod.ts";
const maxHeap: BinaryHeap = new BinaryHeap();
maxHeap.push(...[4, 1, 3, 6, 2]); // 5
@@ -8,7 +7,7 @@ maxHeap.pop(); // 6
maxHeap.peek(); // 4
maxHeap.pop(); // 4
-const minHeap: BinaryHeap = new BinaryHeap(ascend);
+const minHeap: BinaryHeap = new BinaryHeap(ascend);
minHeap.push(...[4, 5, 3, 6, 2]);
minHeap.peek(); // 2
minHeap.pop(); // 2
diff --git a/mod.ts b/mod.ts
index 2af5741..e9e0a2d 100644
--- a/mod.ts
+++ b/mod.ts
@@ -3,7 +3,7 @@
export { Vector } from "./vector.ts";
export { BinaryHeap } from "./binary_heap.ts";
export { ascend, descend } from "./comparators.ts";
-export { randomInt, range, shuffle, swap } from "./common.ts";
+export { count, randomInt, range, shuffle, swap } from "./common.ts";
export type {
compare,
compareDefined,
diff --git a/test_deps.ts b/test_deps.ts
new file mode 100644
index 0000000..391bfb4
--- /dev/null
+++ b/test_deps.ts
@@ -0,0 +1,14 @@
+export {
+ assert,
+ assertEquals,
+ assertStrictEquals,
+ assertThrows,
+} from "https://deno.land/std@0.98.0/testing/asserts.ts";
+
+export {
+ bench,
+ runBenchmarks,
+} from "https://deno.land/std@0.98.0/testing/bench.ts";
+export type { BenchmarkTimer } from "https://deno.land/std@0.98.0/testing/bench.ts";
+
+export { test, TestSuite } from "https://deno.land/x/test_suite@v0.6.4/mod.ts";
diff --git a/trees/bench.ts b/trees/bench.ts
index 0ff9068..1737eda 100644
--- a/trees/bench.ts
+++ b/trees/bench.ts
@@ -1,11 +1,5 @@
-import {
- bench,
- BenchmarkTimer,
- runBenchmarks,
-} from "../deps/std/testing/bench.ts";
-import { BSTree } from "./bs_tree.ts";
-import { RBTree } from "./rb_tree.ts";
-import { range, shuffle } from "../common.ts";
+import { bench, BenchmarkTimer, runBenchmarks } from "../test_deps.ts";
+import { BSTree, range, RBTree, shuffle } from "../mod.ts";
const Trees: (typeof BSTree)[] = [BSTree, RBTree];
const count = 10000;
diff --git a/trees/bs_node_test.ts b/trees/bs_node_test.ts
index d3d3332..29216d8 100644
--- a/trees/bs_node_test.ts
+++ b/trees/bs_node_test.ts
@@ -1,9 +1,10 @@
-import { BSNode } from "./bs_node.ts";
import {
assertEquals,
assertStrictEquals,
-} from "../deps/std/testing/asserts.ts";
-import { test, TestSuite } from "../deps/udibo/test_suite/mod.ts";
+ test,
+ TestSuite,
+} from "../test_deps.ts";
+import { BSNode } from "./bs_node.ts";
interface NodeTests {
parent: BSNode;
diff --git a/trees/bs_tree_test.ts b/trees/bs_tree_test.ts
index 3ebc17c..7511000 100644
--- a/trees/bs_tree_test.ts
+++ b/trees/bs_tree_test.ts
@@ -1,10 +1,6 @@
-import {
- assertEquals,
- assertStrictEquals,
-} from "../deps/std/testing/asserts.ts";
-import { BSTree } from "./bs_tree.ts";
-import { ascend, descend } from "../comparators.ts";
+import { assertEquals, assertStrictEquals } from "../test_deps.ts";
import { Container, MyMath } from "../test_common.ts";
+import { ascend, BSTree, descend } from "../mod.ts";
Deno.test("BSTree with default ascend comparator", () => {
const trees: BSTree[] = [new BSTree(), new BSTree()];
diff --git a/trees/rb_node_test.ts b/trees/rb_node_test.ts
index 96e0441..52f622a 100644
--- a/trees/rb_node_test.ts
+++ b/trees/rb_node_test.ts
@@ -1,5 +1,5 @@
+import { assertStrictEquals } from "../test_deps.ts";
import { RBNode } from "./rb_node.ts";
-import { assertStrictEquals } from "../deps/std/testing/asserts.ts";
Deno.test("RBNode", () => {
const parent: RBNode = new RBNode(null, 5);
diff --git a/trees/rb_tree_test.ts b/trees/rb_tree_test.ts
index 2820aba..11c5c7b 100644
--- a/trees/rb_tree_test.ts
+++ b/trees/rb_tree_test.ts
@@ -1,10 +1,6 @@
-import {
- assertEquals,
- assertStrictEquals,
-} from "../deps/std/testing/asserts.ts";
-import { RBTree } from "./rb_tree.ts";
-import { ascend, descend } from "../comparators.ts";
+import { assertEquals, assertStrictEquals } from "../test_deps.ts";
import { Container, MyMath } from "../test_common.ts";
+import { ascend, descend, RBTree } from "../mod.ts";
Deno.test("RBTree with default ascend comparator", () => {
const trees: RBTree[] = [new RBTree(), new RBTree()];
diff --git a/vector_bench.ts b/vector_bench.ts
index d1dca81..f4757fd 100644
--- a/vector_bench.ts
+++ b/vector_bench.ts
@@ -1,10 +1,5 @@
-import {
- bench,
- BenchmarkTimer,
- runBenchmarks,
-} from "./deps/std/testing/bench.ts";
-import { Vector } from "./vector.ts";
-import { range, shuffle } from "./common.ts";
+import { bench, BenchmarkTimer, runBenchmarks } from "./test_deps.ts";
+import { range, shuffle, Vector } from "./mod.ts";
const runs = 100;
const count = 25000;
diff --git a/vector_test.ts b/vector_test.ts
index 5bbc43d..f977407 100644
--- a/vector_test.ts
+++ b/vector_test.ts
@@ -3,11 +3,11 @@ import {
assertEquals,
assertStrictEquals,
assertThrows,
-} from "./deps/std/testing/asserts.ts";
-import { test, TestSuite } from "./deps/udibo/test_suite/mod.ts";
-import { descend } from "./comparators.ts";
-import { Vector } from "./vector.ts";
+ test,
+ TestSuite,
+} from "./test_deps.ts";
import { MyMath, Thing } from "./test_common.ts";
+import { descend, Vector } from "./mod.ts";
const vectorTests: TestSuite = new TestSuite({ name: "Vector" });