Skip to content

lichrot/phf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[@qnd/phf] Quick-and-Dirty Perfect Hash Function Generation

Apache-2.0 JSR Version NPM Version

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).

About

Perfect Hash Function primitives generator.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors