UNPKG

ciorent

Version:

A lightweight, low-overhead concurrency library

18 lines (17 loc) 463 B
import { type Extend } from "./utils.js"; /** * Describe a mutex. */ export type Mutex = [Promise<void>]; /** * Create a mutex. */ export declare const init: () => Mutex; /** * Acquire a mutex. */ export declare const acquire: (mu: Extend<Mutex>) => Promise<() => void>; /** * Automatically acquire and run a task. */ export declare const run: <const T extends (...args: any[]) => Promise<any>>(mu: Extend<Mutex>, fn: T, ...args: Parameters<T>) => ReturnType<T>;