From c1885762c04ba7d567aee66764b7c665531a29c3 Mon Sep 17 00:00:00 2001 From: Philippe Tessier Date: Tue, 9 Jan 2024 18:05:12 -0500 Subject: [PATCH] Polish hash function --- packages/react/src/pages/home.tsx | 3 +-- packages/sdk/src/assignment/hashing.ts | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/react/src/pages/home.tsx b/packages/react/src/pages/home.tsx index 69671de..39a46a7 100644 --- a/packages/react/src/pages/home.tsx +++ b/packages/react/src/pages/home.tsx @@ -1,5 +1,5 @@ import { useMemo } from "react"; -import { getHash, getInstance } from "sdk"; +import { getInstance } from "sdk"; import styles from "./home.module.css"; import mxLogo from "/mx.svg"; import reactLogo from "/react.svg"; @@ -53,7 +53,6 @@ export function HomePage() {

Assignment

{JSON.stringify(assignment, null, 2)} -
test: {getHash("experiment-1", 2).toPrecision(10)}
); } diff --git a/packages/sdk/src/assignment/hashing.ts b/packages/sdk/src/assignment/hashing.ts index 513a8ce..e656dda 100644 --- a/packages/sdk/src/assignment/hashing.ts +++ b/packages/sdk/src/assignment/hashing.ts @@ -9,15 +9,6 @@ import { stringify } from "../utils"; export function getHash(experimentKey: string, subjectKey: unknown): number { const key = [experimentKey, stringify(subjectKey)].join(); - return hash(key); -} - -/** - * Hashes a string to a number between 0 and 1 - * @param key - The string to hash - * @returns A hash value between 0 and 1 - */ -function hash(key: string): number { return (hashFnv32a(key) % 1000) / 1000; }