One function to rule them all generate all the primitives needed to
implement a perfect hash function lookup.
There is also a TypeScript reference implemenetation that turns primitives into TypeScript code.
import { genPhfPrimitives, genPhfTs } from "@qnd/phf";
const dict = { let: 0, const: 1, if: 2, else: 3 };
const primitives = genPhfPrimitives(dict);
const code = genPhfTs(primitives);
Deno.writeTextFileSync("./phf.ts", code);Choose your fighter:
npm install @qnd/phf
yarn add @qnd/phf
pnpm install @qnd/phf
deno install jsr:@qnd/phf# Run tests
deno task test
# Transpile to JS + D.TS
deno task transpile
# Run publishing in dry mode
deno task dry-run
# Prepare for publishing (does all of the above)
deno task prepare
# Publish to JSR and NPM
deno task publishThis work is licensed under Apache-2.0 (see NOTICE).