Skip to content

Commit

Permalink
Support JSR
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Apr 6, 2024
1 parent f61dbcb commit e7032ac
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 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/publish-on-tag@0.1.3
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ jobs:
run: |
deno task test
timeout-minutes: 5
- name: JSR publish (dry-run)
run: |
deno publish --dry-run
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"lock": false,
"name": "@lambdalisue/async",
"version": "0.0.0",
"exports": "./mod.ts",
"imports": {
"https://deno.land/x/async@$MODULE_VERSION/": "./"
},
Expand Down

0 comments on commit e7032ac

Please sign in to comment.