asynchronously acquire a permit, waiting until one becomes available, or throw if aborted
Optionaloptions: { priority?: number; signal?: AbortSignal; timeout?: number }Optionalpriority?: numberIf provided, the acquire operation will be given priority over other operations.
The default priority is 0.
Optionalsignal?: AbortSignalsame signature as fetch(), but for aborting operations. If provided, the operation will be aborted when the signal is aborted.
Optionaltimeout?: 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
Optionaloptions: { priority?: number; signal?: AbortSignal; timeout?: number }Optionalpriority?: numberIf provided, the acquire operation will be given priority over other operations.
The default priority is 0.
Optionalsignal?: AbortSignalsame signature as fetch(), but for aborting operations. If provided, the operation will be aborted when the signal is aborted.
Optionaltimeout?: numbertimeout in milliseconds. This works in tandem with the signal option, whichever triggers first (signal or timeout) will abort the operation.