Package: effect
Module: TxSemaphore
Determines if the provided value is a TxSemaphore.
When to use
Use to narrow an unknown value before treating it as a TxSemaphore.
Example (Checking semaphore values)
import { Effect, TxSemaphore } from "effect"
const program = Effect.gen(function*() {
const semaphore = yield* TxSemaphore.make(5)
const notSemaphore = { some: "object" }
console.log(TxSemaphore.isTxSemaphore(semaphore)) // true
console.log(TxSemaphore.isTxSemaphore(notSemaphore)) // false
// Useful for runtime type checking in generic functions
if (TxSemaphore.isTxSemaphore(semaphore)) {
const available = yield* TxSemaphore.available(semaphore)
console.log(`Available permits: ${available}`)
}
})
See
make for creating a TxSemaphoreSignature
declare const isTxSemaphore: (u: unknown) => u is TxSemaphore
Since v4.0.0