effect-io-ai

Package: effect
Module: Hash

Hash.Hash

A type that represents an object that can be hashed.

When to use

Use to let a custom type provide its own stable hash value.

Details

Objects implementing this interface provide a method to compute their hash value, which is used for efficient comparison and storage operations.

Example (Implementing Hash)

import { Hash } from "effect"

class MyClass implements Hash.Hash {
  constructor(private value: number) {}

  [Hash.symbol](): number {
    return Hash.hash(this.value)
  }
}

const instance = new MyClass(42)
console.log(instance[Hash.symbol]()) // hash value of 42

Signature

export interface Hash {
  [symbol](): number
}

Source

Since v2.0.0