@mdekstrand/locks@0.1.4Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
mdekstrand/locksWorks with
•JSR Score88%•This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers




Published7 months ago (0.1.4)
Locking primitives for TypeScript
Locking primitives for TypeScript
This module provides various locking primitives for modern TypeScript:
import {Semaphore} from "@mdekstrand/locks"; const lock = new Semaphore(2); function myContentiousTask() { using _lock = await lock.acquire(); // do the work // the lock is automatically released at end of function! }
It is heavily inspired by asyncutil, particularly in its API, with my own take on the ideas and a focus on simplicity and safety over extremes in performance (but it does try to avoid unnecessarily inefficient constructs).
It has a single dependency — deque, a TypeScript port of denque, used to
implement Notify (which in turn is used to implement many other elements).
Built and signed on
GitHub Actions
Add Package
deno add jsr:@mdekstrand/locks
Import symbol
import * as locks from "@mdekstrand/locks";
Import directly with a jsr specifier
import * as locks from "jsr:@mdekstrand/locks";
Add Package
pnpm i jsr:@mdekstrand/locks
pnpm dlx jsr add @mdekstrand/locks
Import symbol
import * as locks from "@mdekstrand/locks";
Add Package
yarn add jsr:@mdekstrand/locks
yarn dlx jsr add @mdekstrand/locks
Import symbol
import * as locks from "@mdekstrand/locks";
Add Package
vlt install jsr:@mdekstrand/locks
Import symbol
import * as locks from "@mdekstrand/locks";
Add Package
npx jsr add @mdekstrand/locks
Import symbol
import * as locks from "@mdekstrand/locks";
Add Package
bunx jsr add @mdekstrand/locks
Import symbol
import * as locks from "@mdekstrand/locks";