effect-io-ai

Package: effect
Module: Hash

Hash.isHash

Checks whether a value implements the Hash interface.

When to use

Use to detect whether an unknown value provides a custom hash implementation.

Details

This function determines whether a given value has the Hash symbol property, indicating that it can provide its own hash value implementation.

Example (Checking for Hash support)

import { Hash } from "effect"

class MyHashable implements Hash.Hash {
  [Hash.symbol]() {
    return 42
  }
}

const obj = new MyHashable()
console.log(Hash.isHash(obj)) // true
console.log(Hash.isHash({})) // false
console.log(Hash.isHash("string")) // false

Signature

declare const isHash: (u: unknown) => u is Hash

Source

Since v2.0.0