@picosearch/bk-tree
Version:
Simple, zero dependency, type-safe implementation of a BK-Tree data structure.
12 lines (11 loc) • 391 B
TypeScript
export type BKTreeNode = [word: string, children?: Record<number, BKTreeNode>];
export type DistanceFunction = (a: string, b: string) => number;
export interface IBKTree {
insert: (word: string) => void;
lookup: (query: string) => string | null;
find: (query: string, options?: {
maxError?: number;
limit?: number;
}) => string[];
toJSON: () => string;
}