Skip to main content
Module

x/rimbu/mod.ts>Hasher.createValueOfHasher

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function Hasher.createValueOfHasher
import { Hasher } from "https://deno.land/x/rimbu@0.13.1/mod.ts";
const { createValueOfHasher } = Hasher;

Returns a Hasher instance that hashes the .valueOf value of the given object using the given valueHasher for instances of given cls class.

Examples

Example 1

const h = Hasher.createValueOfHasher(Date)
console.log(h.isValid(new Boolean(true)))
// => false
const d1 = new Date()
const d2 = new Date(d1)
console.log(h.hash(d1) === h.hash(d2))
// => true

Type Parameters

T extends { valueOf(): V; }
V

Parameters

cls: { new (): T; }
  • the class containing the contructur to check for validity of a given object
optional
valueHasher: Hasher<V> = [UNSUPPORTED]
  • the Hasher instance to use for the .valueOf values