@fairfox/adorn
Version:
Powerfully performant keyword matching and annotation for the DOM
35 lines • 1.36 kB
TypeScript
declare type KwListMap = Map<string, string[]>;
declare type Opts = {
tag: string;
element?: CustomElementConstructor;
elementMethods?: Array<[string, (args: any) => void]>;
getAttrs?: (id: string) => Array<[string, string]>;
shouldSkipChars?: boolean;
};
export declare class Match {
private readonly _kw;
private wordChars;
private skipChars;
private readonly trieCI;
private readonly trieCS;
readonly opts: Opts;
constructor(insensitive: KwListMap | null, sensitive: KwListMap | null, opts: Opts);
getDetails(): {
trieAsString: string;
};
/**
* @param id is the associated id
* @param keyword is the target text to match against
* @param caseSensitive is whether to ONLY map the chars with their given case
*/
addKw(id: string, keyword: string, caseSensitive: boolean): void;
areKwListMapsValid: (insensitive: KwListMap | null, sensitive: KwListMap | null) => boolean;
addKws(KwListMap: KwListMap | null, caseSensitive: boolean): void;
getMatchIndexes(sentence: string): [string, number, number][];
extractMatchIds(sentence: string): string[];
extractDirtyMatches(sentence: string): Map<string, string>;
replaceKws(sentence: string): string;
wrapKwsWithHtml(sentence: string): string;
}
export {};
//# sourceMappingURL=index.d.ts.map