Hyperlinkv0.8.0-beta.28

Hash

Hash.combineconsteffect/Hash.ts:237
(b: number): (self: number) => number
(self: number, b: number): number

Combines two hash values into a single hash value.

When to use

Use to build a hash for a composite value by folding together hash values for its parts.

Details

Supports both direct and pipeable usage. The implementation combines two hash values with (self * 53) ^ b.

Example (Combining hash values)

import { Hash, pipe } from "effect"

// Can also be used with pipe

const hash1 = Hash.hash("hello")
const hash2 = Hash.hash("world")

// Combine two hash values
const combined = Hash.combine(hash2)(hash1)
console.log(combined)
const result = pipe(hash1, Hash.combine(hash2))
Source effect/Hash.ts:2374 lines
export const combine: {
  (b: number): (self: number) => number
  (self: number, b: number): number
} = dual(2, (self: number, b: number): number => (self * 53) ^ b)
Referenced by 1 symbols