florid
v0.1.0
Published
Generate nice human-readable unique identifiers from word dictionaries
Maintainers
Readme
florid
Generate nice human-readable unique identifiers from word dictionaries.
TypeScript/JavaScript bindings for florid via WebAssembly. Works in both Node.js and browsers.
Installation
npm install floridUsage
import { florid, isValid, normalize } from "florid";
// Generate an ID of specific length (5-36 characters)
const id = await florid(20); // e.g., "paper-quinacrine-sir"
// Validate an ID
const valid = await isValid("red-cat-dog"); // true
// Normalize (lowercase) an ID
const normalized = await normalize("RED-CAT-DOG"); // "red-cat-dog"API
florid(length?: number): Promise<string>
Generate a human-readable ID of the specified length (default: 20). Length must be between 5 and 36.
isValid(s: string): Promise<boolean>
Check if a string is a valid florid format.
normalize(s: string): Promise<string | undefined>
Normalize an ID to lowercase. Returns undefined if invalid.
entropyBits(): Promise<number>
Get the entropy in bits per word.
collisionProbability(numIds: number | bigint, numWords: number): Promise<number>
Calculate collision probability for a given number of IDs and word count.
minLength(): Promise<number> / maxLength(): Promise<number>
Get the minimum (5) and maximum (36) allowed lengths.
Constants
MIN_LENGTH = 5MAX_LENGTH = 36
License
MIT
