Hyperlinkv0.8.0-beta.28

TxHashMap

TxHashMap.isTxHashMapconsteffect/TxHashMap.ts:1210
<K, V>(value: unknown): value is TxHashMap<K, V>

Returns true if the specified value is a TxHashMap, false otherwise.

Example (Checking TxHashMap values)

import { Effect, TxHashMap } from "effect"

const program = Effect.gen(function*() {
  const txMap = yield* TxHashMap.make(["key", "value"])

  console.log(TxHashMap.isTxHashMap(txMap)) // true
  console.log(TxHashMap.isTxHashMap({})) // false
  console.log(TxHashMap.isTxHashMap(null)) // false
  console.log(TxHashMap.isTxHashMap("not a map")) // false

  // Useful for type guards in runtime checks
  const validateInput = (value: unknown) => {
    if (TxHashMap.isTxHashMap(value)) {
      // TypeScript now knows this is a TxHashMap
      return Effect.succeed("Valid TxHashMap")
    }
    return Effect.fail("Invalid input")
  }
})
guards
export const isTxHashMap = <K, V>(value: unknown): value is TxHashMap<K, V> => {
  return hasProperty(value, TypeId)
}