diff --git a/.github/workflows/jsr.yml b/.github/workflows/jsr.yml new file mode 100644 index 0000000..2de3f3a --- /dev/null +++ b/.github/workflows/jsr.yml @@ -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/publish-on-tag@0.1.3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25652c8..127de24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,3 +38,6 @@ jobs: run: | deno task test timeout-minutes: 5 + - name: JSR publish (dry-run) + run: | + deno publish --dry-run diff --git a/README.md b/README.md index fee12ab..647f2db 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # async -[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/async) +[![jsr](https://img.shields.io/jsr/v/%40lambdalisue/async?logo=javascript&logoColor=white)](https://jsr.io/@lambdalisue/async) +[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-async?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-async/releases) [![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/async/mod.ts) [![Test](https://github.com/lambdalisue/deno-async/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-async/actions?query=workflow%3ATest) @@ -87,20 +88,24 @@ import { RwLock } from "https://deno.land/x/async@$MODULE_VERSION/rw_lock.ts"; const count = new RwLock(new AsyncValue(0)); // rlock should allow multiple readers at a time -await Promise.all([...Array(10)].map(() => { - return count.rlock(async (count) => { - console.log(await count.get()); - }); -})); +await Promise.all( + [...Array(10)].map(() => { + return count.rlock(async (count) => { + console.log(await count.get()); + }); + }), +); // lock should allow only one writer at a time -await Promise.all([...Array(10)].map(() => { - return count.lock(async (count) => { - const v = await count.get(); - console.log(v); - count.set(v + 1); - }); -})); +await Promise.all( + [...Array(10)].map(() => { + return count.lock(async (count) => { + const v = await count.get(); + console.log(v); + count.set(v + 1); + }); + }), +); ``` ### Mutex diff --git a/deno.jsonc b/deno.jsonc index 780871a..264e08b 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,5 +1,8 @@ { "lock": false, + "name": "@lambdalisue/async", + "version": "0.0.0", + "exports": "./mod.ts", "imports": { "https://deno.land/x/async@$MODULE_VERSION/": "./" }, diff --git a/queue.ts b/queue.ts index e37c173..68360c0 100644 --- a/queue.ts +++ b/queue.ts @@ -1,4 +1,4 @@ -import { Notify, WaitOptions } from "./notify.ts"; +import { Notify, type WaitOptions } from "./notify.ts"; /** * A queue implementation that allows for adding and removing elements, with optional waiting when diff --git a/stack.ts b/stack.ts index bbb6c7e..57a6464 100644 --- a/stack.ts +++ b/stack.ts @@ -1,4 +1,4 @@ -import { Notify, WaitOptions } from "./notify.ts"; +import { Notify, type WaitOptions } from "./notify.ts"; /** * A stack implementation that allows for adding and removing elements, with optional waiting when