@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
51 lines (50 loc) • 1.5 kB
TypeScript
export type WalkFn = (s: string, v: any) => Promise<boolean>;
declare class LeafNode {
key: string;
val: any;
constructor(key: string, val: any);
}
declare class Edge {
label: number;
node: Node;
constructor(label: number, node: Node);
}
declare class Node {
leaf: LeafNode | null;
prefix: string;
edges: Edge[];
isLeaf(): boolean;
addEdge(e: Edge): void;
updateEdge(label: number, node: Node): void;
getEdge(label: number): Node | null;
delEdge(label: number): void;
mergeChild(): void;
}
export declare class Tree {
private root;
private size;
constructor();
static newFromMap(m: Map<string, any> | {
[key: string]: any;
} | null): Tree;
len(): number;
insert(s: string, v: any): [any, boolean];
delete(s: string): [any, boolean];
deletePrefix(s: string): Promise<number>;
_deletePrefix(parent: Node | null, n: Node, prefix: string): Promise<number>;
get(s: string): [any, boolean];
longestPrefix(s: string): [string, any, boolean];
minimum(): [string, any, boolean];
maximum(): [string, any, boolean];
walk(fn: WalkFn): Promise<void>;
walkPrefix(prefix: string, fn: WalkFn): Promise<void>;
walkPath(path: string, fn: WalkFn): Promise<void>;
toMap(): Promise<{
[key: string]: any;
}>;
}
export declare function createTree(): Tree;
export declare function createTreeFromMap(m: Map<string, any> | {
[key: string]: any;
} | null): Tree;
export {};