HashA 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 42models
Source effect/Hash.ts:653 lines
Referenced by 2 symbols