asynchronously acquire a permit, waiting until one becomes available, or throw if aborted
Optional
options: { priority?: number; signal?: AbortSignal; timeout?: number }Optional
priority?: numberIf provided, the acquire operation will be given priority over other operations.
The default priority is 0.
Optional
signal?: AbortSignalsame signature as fetch(), but for aborting operations. If provided, the operation will be aborted when the signal is aborted.
Optional
timeout?: numbertimeout in milliseconds. This works in tandem with the signal option, whichever triggers first (signal or timeout) will abort the operation.
synchronously acquire a permit if one is available, otherwise return undefined
release a permit, making it available for other operations
run a function with a semaphore, acquiring a permit before running and releasing it after
Optional
options: { priority?: number; signal?: AbortSignal; timeout?: number }Optional
priority?: numberIf provided, the acquire operation will be given priority over other operations.
The default priority is 0.
Optional
signal?: AbortSignalsame signature as fetch(), but for aborting operations. If provided, the operation will be aborted when the signal is aborted.
Optional
timeout?: numbertimeout in milliseconds. This works in tandem with the signal option, whichever triggers first (signal or timeout) will abort the operation.