(u: unknown): u is TxSemaphoreDetermines 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}`)
}
})guardsmake
Source effect/TxSemaphore.ts:7071 lines
export const const isTxSemaphore: (
u: unknown
) => u is 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}`)
}
})
isTxSemaphore = (u: unknownu: unknown): u: unknownu is TxSemaphore => import hasPropertyhasProperty(u: unknownu, const TypeId: "~effect/transactions/TxSemaphore"TypeId)