Skip to content

Commit

Permalink
Merge pull request #4 from lambdalisue/support-jsr
Browse files Browse the repository at this point in the history
Support jsr
  • Loading branch information
lambdalisue authored Apr 6, 2024
2 parents ee4d709 + 5c2a489 commit d70f0c8
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 108 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: jsr

env:
DENO_VERSION: 1.x

on:
push:
tags:
- "v*"

permissions:
contents: read
id-token: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Publish
run: |
deno run -A jsr:@david/[email protected]
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ on:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
Expand All @@ -30,11 +31,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Test
run: |
deno task test
timeout-minutes: 5
- name: JSR publish (dry-run)
run: |
deno publish --dry-run
50 changes: 0 additions & 50 deletions .github/workflows/udd.yml

This file was deleted.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# streamtools

[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/streamtools)
[![jsr](https://img.shields.io/jsr/v/%40lambdalisue/streamtools?logo=javascript&logoColor=white)](https://jsr.io/@lambdalisue/streamtools)
[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-streamtools?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-streamtools/releases)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/streamtools/mod.ts)
[![Test](https://github.com/lambdalisue/deno-streamtools/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-streamtools/actions?query=workflow%3ATest)

This is a [Deno][deno] module that provides utilities for handling Streams API.

[deno]: https://deno.land/
This is a TypeScript module that provides utilities for handling Streams API.

## Usage

Expand Down Expand Up @@ -138,7 +137,7 @@ console.log(results); // [1, 2, 3]
and concatenates them into a single `Uint8Array`.

```ts
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "jsr:@std/assert";
import { readAll } from "./read_all.ts";

const encoder = new TextEncoder();
Expand All @@ -157,7 +156,7 @@ assertEquals(result, encoder.encode("HelloWorld"));
units.

```ts
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "jsr:@std/assert";
import { writeAll } from "./write_all.ts";

const encoder = new TextEncoder();
Expand Down
21 changes: 0 additions & 21 deletions channel_bench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { channel as channelV3 } from "https://deno.land/x/[email protected]/channel.ts#=";
import { channel } from "./channel.ts";

Deno.bench("channel", { group: "channel", baseline: true }, async () => {
Expand All @@ -20,23 +19,3 @@ Deno.bench("channel", { group: "channel", baseline: true }, async () => {
};
await Promise.all([producer(), consumer()]);
});

Deno.bench("channelV3", { group: "channel" }, async () => {
const { reader, writer } = channelV3<number>();

const producer = async () => {
const w = writer.getWriter();
for (let i = 0; i < 100000; i++) {
await w.ready;
await w.write(i);
}
w.releaseLock();
await writer.close();
};
const consumer = async () => {
for await (const _ of reader) {
// Do NOTHING
}
};
await Promise.all([producer(), consumer()]);
});
10 changes: 2 additions & 8 deletions channel_test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
assertEquals,
assertRejects,
} from "https://deno.land/[email protected]/testing/asserts.ts";
import {
deadline,
DeadlineError,
} from "https://deno.land/[email protected]/async/mod.ts";
import { assertEquals, assertRejects } from "@std/assert";
import { deadline, DeadlineError } from "@std/async";
import { provide } from "./provide.ts";
import { pop } from "./pop.ts";
import { push } from "./push.ts";
Expand Down
10 changes: 2 additions & 8 deletions collect_test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
assertEquals,
assertRejects,
} from "https://deno.land/[email protected]/testing/asserts.ts";
import {
deadline,
DeadlineError,
} from "https://deno.land/[email protected]/async/deadline.ts";
import { assertEquals, assertRejects } from "@std/assert";
import { deadline, DeadlineError } from "@std/async";
import { collect } from "./collect.ts";

Deno.test("collect returns an empty array for an empty stream", async () => {
Expand Down
13 changes: 10 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"name": "@lambdalisue/streamtools",
"version": "0.0.0",
"exports": "./mod.ts",
"tasks": {
"test": "deno test --no-lock --unstable -A --parallel --doc",
"check": "deno check --no-lock --unstable $(find . -name '*.ts')",
"upgrade": "deno run --no-lock -A https://deno.land/x/udd/main.ts $(find . -name '*.ts')"
"test": "deno test -A --parallel --doc --shuffle",
"check": "deno check **/*.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@^0.221.0",
"@std/async": "jsr:@std/async@^0.221.0",
"@std/bytes": "jsr:@std/bytes@^0.221.0"
}
}
2 changes: 1 addition & 1 deletion pipe_through_from_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "@std/assert";
import { collect } from "./collect.ts";
import { channel } from "./channel.ts";
import { pipeThroughFrom } from "./pipe_through_from.ts";
Expand Down
2 changes: 1 addition & 1 deletion pop_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "@std/assert";
import { pop } from "./pop.ts";

Deno.test("pop", async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion provide_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "@std/assert";
import { provide } from "./provide.ts";

Deno.test("provide writes all values to stream", async () => {
Expand Down
2 changes: 1 addition & 1 deletion push_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "@std/assert";
import { push } from "./push.ts";

Deno.test("push", async (t) => {
Expand Down
4 changes: 2 additions & 2 deletions read_all.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { concat } from "https://deno.land/[email protected]/bytes/mod.ts";
import { concat } from "@std/bytes";
import { collect } from "./collect.ts";

/**
Expand Down Expand Up @@ -33,5 +33,5 @@ export async function readAll(
options: PipeOptions = {},
): Promise<Uint8Array> {
const chunks = await collect(stream, options);
return concat(...chunks);
return concat(chunks);
}
2 changes: 1 addition & 1 deletion read_all_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals } from "@std/assert";
import { readAll } from "./read_all.ts";

Deno.test("readAll", async () => {
Expand Down
6 changes: 3 additions & 3 deletions write_all_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { concat } from "https://deno.land/[email protected]/bytes/mod.ts";
import { assertEquals } from "@std/assert";
import { concat } from "@std/bytes";
import { writeAll } from "./write_all.ts";

Deno.test("writeAll", async (t) => {
Expand All @@ -14,7 +14,7 @@ Deno.test("writeAll", async (t) => {
},
});
await writeAll(stream, encoder.encode("HelloWorld"), { chunkSize: 3 });
assertEquals(concat(...chunks), encoder.encode("HelloWorld"));
assertEquals(concat(chunks), encoder.encode("HelloWorld"));
assertEquals(chunks, [
encoder.encode("Hel"),
encoder.encode("loW"),
Expand Down

0 comments on commit d70f0c8

Please sign in to comment.