OVERVIEW
FlashFuzzy API
FlashFuzzy exposes a single class, FlashFuzzy, that wraps the WebAssembly module. All search logic runs in the WASM sandbox; the JS surface is intentionally thin.
npm install flashfuzzy
METHOD
FlashFuzzy.create()
static FlashFuzzy.create(): Promise<FlashFuzzy>Returns:
Promise<FlashFuzzy>Initialises the WebAssembly module and returns a ready FlashFuzzy instance. Must be awaited before any other call. Safe to call once per page load.
import { FlashFuzzy } from "flashfuzzy";
const ff = await FlashFuzzy.create();
console.log("FlashFuzzy ready");METHOD
ff.index()
ff.index(records: T[]): voidReturns:
voidTokenises each record and builds the Bloom filter index. Accepts arrays of strings, objects, or JSON. Fields are concatenated for multi-field search.
ff.index([
{ id: 1, name: "React Hooks", tags: ["react", "js"] },
{ id: 2, name: "Vue Composition API", tags: ["vue", "js"] },
]);METHOD
ff.search()
ff.search(query: string): Hit[]Returns:
Hit[]Runs the Bloom → Bitap → Score → Rank pipeline and returns hits sorted by score descending. Typo-tolerant up to 2 edits. Supports phrase, AND, and OR queries.
const hits = ff.search("raect hoks"); // typo-tolerant
for (const h of hits) {
console.log(h.id, h.score, h.snippet);
}Hit
| Field | Type | Description |
|---|---|---|
id | unknown | Original record identifier as provided to index() |
score | number | Relevance score 0.0–1.0 (higher is better) |
snippet | string | Surrounding text excerpt with match context |
METHOD
ff.clear()
ff.clear(): voidReturns:
voidClears all indexed records and resets the BSS store. The instance is immediately ready to index a new dataset.
ff.clear();
console.log("Index cleared, ready for new records");