@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
83 lines (82 loc) • 3.08 kB
TypeScript
import { Tree as RadixTree } from '../radix';
import { Dimension, DimensionFlag } from './dimensions';
import { LockType, WalkContext } from './support';
export interface Config<T> {
shifter: Shifter<T>;
}
export interface Shifter<T> {
forEachInDimension(n: T, d: number, f: (t: T) => boolean): void;
insert(old: T, newItem: T): T;
insertInto(old: T, newItem: T, dimension: Dimension): T;
delete(v: T, dimension: Dimension): [boolean, boolean];
shift(v: T, dimension: Dimension, exact: boolean): [T, boolean, DimensionFlag];
}
export declare class NodeShiftTree<T> {
tree: RadixTree;
dims: Dimension;
shifter: Shifter<T>;
private mu;
constructor(cfg: Config<T>);
static new<T>(cfg: Config<T>): NodeShiftTree<T>;
delete(key: string): void;
deleteAll(key: string): Promise<void>;
deletePrefix(prefix: string): Promise<number>;
private deleteInternal;
deletePrefixAll(prefix: string): Promise<number>;
increment(d: number): NodeShiftTree<T>;
insertIntoCurrentDimension(s: string, v: T): [T, boolean];
insertIntoValuesDimension(s: string, v: T): [T, boolean];
insertRawWithLock(s: string, v: any): [any, boolean];
insertWithLock(s: string, v: T): [T, boolean];
len(): number;
canLock(): boolean;
lock(writable: boolean): () => void;
longestPrefix(s: string, exact: boolean, predicate?: (v: T) => boolean): [string, T];
longestPrefixAll(s: string): [string, boolean];
getRaw(s: string): [T, boolean];
walkPrefixRaw(prefix: string, walker: (key: string, value: T) => Promise<boolean>): Promise<void>;
shape(d: number, v: number): NodeShiftTree<T>;
toString(): string;
get(s: string): T;
forEachInDimension(s: string, d: number, f: (t: T) => boolean): void;
has(s: string): boolean;
private clone;
private shift;
private getInternal;
}
export type WalkFunc<T> = (key: string, value: T) => [boolean, Error | null];
export interface NodeShiftTreeWalkerConfig<T> {
tree: NodeShiftTree<T>;
handle: (s: string, v: T, exact: DimensionFlag) => Promise<[boolean, Error | null]>;
prefix?: string;
lockType?: LockType;
noShift?: boolean;
exact?: boolean;
debug?: boolean;
walkContext?: WalkContext<T> | undefined;
}
export declare class NodeShiftTreeWalker<T> {
tree: NodeShiftTree<T>;
handle: (s: string, v: T, exact: DimensionFlag) => Promise<[boolean, Error | null]>;
prefix: string;
lockType: LockType;
noShift: boolean;
exact: boolean;
debug: boolean;
walkContext?: WalkContext<T> | undefined;
private skipPrefixes;
constructor(config: NodeShiftTreeWalkerConfig<T>);
extend(): NodeShiftTreeWalker<T>;
skipPrefix(...prefixes: string[]): void;
shouldSkip(s: string): boolean;
walk(): Promise<Error | null>;
private resetLocalState;
private toT;
}
export interface WalkConfig<T> {
prefix?: string;
callback: (ctx: WalkContext<T>, s: string, t: T) => [boolean, Error | null];
lockType?: LockType;
noShift?: boolean;
exact?: boolean;
}