-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from lambdalisue/support-jsr
Support jsr
- Loading branch information
Showing
15 changed files
with
62 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
@@ -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(); | ||
|
@@ -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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => { | ||
|
@@ -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()]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
||
/** | ||
|
@@ -33,5 +33,5 @@ export async function readAll( | |
options: PipeOptions = {}, | ||
): Promise<Uint8Array> { | ||
const chunks = await collect(stream, options); | ||
return concat(...chunks); | ||
return concat(chunks); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { | ||
|
@@ -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"), | ||
|