@tanishiking/aho-corasick
Version:
TypeScript implementation of the Aho-Corasick algorithm for efficient string matching
40 lines (39 loc) • 1.07 kB
TypeScript
export declare class State {
private _failure;
private rootState;
private readonly _depth;
private _emits;
private success;
constructor(depth: number);
get failure(): State | null;
set failure(state: State | null);
get depth(): number;
get emits(): string[];
/**
* Add outputs to the state.
*
* @param keywords the list of outputs.
*/
addEmits(keywords: string[]): void;
/**
* Transit to the next state with the given character.
*
* @param char input character for the transition.
*/
nextState(char: string, ignoreRootState?: boolean): State | null;
/**
* Create a new state and add a transition to the new state
* with the given character.
*
* @param char input character for moving to the new state.
*/
addState(char: string): State;
/**
* Return the list of reachable states with one step.
*/
getStates(): State[];
/**
* Get the possible char to move to the next state.
*/
getTransitions(): string[];
}