@qnd/phf
v1.0.0
Published
Perfect Hash Function primitives generator.
Readme
[@qnd/phf] Quick-and-Dirty Perfect Hash Function Generation
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.
[💀] Example
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);[💾] Installation
Choose your fighter:
npm install @qnd/phf
yarn add @qnd/phf
pnpm install @qnd/phf
deno install jsr:@qnd/phf[🖥️] Tasks
# 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 publish[📝] License
This work is licensed under Apache-2.0 (see NOTICE).
