Skip to main content
Module

x/rimbu/mod.ts>Hasher.anyShallowHasher

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

Returns a Hasher instance that hashes any value, but only traverses into an object or array to hash its elements one level deep. After one level, it will use toString.

Examples

Example 1

const h = Hasher.anyShallowHasher()
console.log(h.hash({ a: 1, b: 2 }) === h.hash({ b: 2, a: 1 }))
// => true
console.log(h.hash([{ a: 1, b: 2 }]) === h.hash([{ b: 2, a: 1 }]))
// => false