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

Commit

Permalink
Upgrade deno to 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleJune committed Jun 12, 2021
1 parent cbc4b0b commit f09eea3
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 120 deletions.
10 changes: 10 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
comment: false
codecov:
require_ci_to_pass: true
coverage:
status:
project:
default:
informational: true
ignore:
- examples
71 changes: 32 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -24,19 +24,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@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
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
Expand All @@ -47,15 +47,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_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
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
Expand All @@ -74,15 +74,15 @@ 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
JavaScript code within the body of the script tag.

```html
<script type="module">
import { Vector } from "./collections_v0.11.0.js";
import { Vector } from "./collections_v0.11.1.js";
</script>
```

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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<number> = new BinaryHeap();
maxHeap.push(...[4, 1, 3, 6, 2]); // 5
Expand All @@ -134,7 +136,7 @@ maxHeap.pop(); // 6
maxHeap.peek(); // 4
maxHeap.pop(); // 4

const minHeap: BinaryHeap<number> = new BinaryHeap(ascend);
const minHeap: BinaryHeap<number> = new BinaryHeap<number>(ascend);
minHeap.push(...[4, 5, 3, 6, 2]);
minHeap.peek(); // 2
minHeap.pop(); // 2
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bench.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
5 changes: 2 additions & 3 deletions binary_heap_test.ts
Original file line number Diff line number Diff line change
@@ -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<number> = new BinaryHeap();
Expand Down
8 changes: 4 additions & 4 deletions common_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });

Expand Down
4 changes: 2 additions & 2 deletions comparators_test.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
6 changes: 0 additions & 6 deletions deps/std/testing/asserts.ts

This file was deleted.

5 changes: 0 additions & 5 deletions deps/std/testing/bench.ts

This file was deleted.

1 change: 0 additions & 1 deletion deps/udibo/test_suite/mod.ts

This file was deleted.

5 changes: 2 additions & 3 deletions examples/binary_heap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BinaryHeap } from "../binary_heap.ts";
import { ascend } from "../comparators.ts";
import { ascend, BinaryHeap } from "../mod.ts";

const maxHeap: BinaryHeap<number> = new BinaryHeap();
maxHeap.push(...[4, 1, 3, 6, 2]); // 5
Expand All @@ -8,7 +7,7 @@ maxHeap.pop(); // 6
maxHeap.peek(); // 4
maxHeap.pop(); // 4

const minHeap: BinaryHeap<number> = new BinaryHeap(ascend);
const minHeap: BinaryHeap<number> = new BinaryHeap<number>(ascend);
minHeap.push(...[4, 5, 3, 6, 2]);
minHeap.peek(); // 2
minHeap.pop(); // 2
Expand Down
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions test_deps.ts
Original file line number Diff line number Diff line change
@@ -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";
10 changes: 2 additions & 8 deletions trees/bench.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 4 additions & 3 deletions trees/bs_node_test.ts
Original file line number Diff line number Diff line change
@@ -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<number>;
Expand Down
8 changes: 2 additions & 6 deletions trees/bs_tree_test.ts
Original file line number Diff line number Diff line change
@@ -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<number>[] = [new BSTree(), new BSTree()];
Expand Down
2 changes: 1 addition & 1 deletion trees/rb_node_test.ts
Original file line number Diff line number Diff line change
@@ -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<number> = new RBNode(null, 5);
Expand Down
8 changes: 2 additions & 6 deletions trees/rb_tree_test.ts
Original file line number Diff line number Diff line change
@@ -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<number>[] = [new RBTree(), new RBTree()];
Expand Down
Loading

0 comments on commit f09eea3

Please sign in to comment.