Skip to content

hashToUnitInterval

function hashToUnitInterval(input, seed?): number;

Defined in: hash.ts:82

Map a string deterministically onto the half-open unit interval [0, 1). Used to pick a bucket within a split’s cumulative weight range.

Parameter Type Default value
input string undefined
seed? number 0

number

import { hashToUnitInterval } from "@xtandard/flags";
const bucket = hashToUnitInterval("user-42"); // → e.g. 0.3141… (always in [0, 1))