Hyperlinkv0.8.0-beta.28

Hash

Hash.isHashconsteffect/Hash.ts:304
(u: unknown): u is Hash

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
guards
Source effect/Hash.ts:3041 lines
export const isHash = (u: unknown): u is Hash => hasProperty(u, symbol)
Referenced by 1 symbols