Hyperlinkv0.8.0-beta.28

Hash

Hash.Hashinterfaceeffect/Hash.ts:65
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
models
Source effect/Hash.ts:653 lines
export interface Hash {
  [symbol](): number
}
Referenced by 2 symbols