Urara-Blog/node_modules/.pnpm-store/v3/files/eb/2d0d94241d5be219239fe598bc03d75738bb7c57502862c85da71f93f1f218ceb7d00883f8488464ebcc4182d53137de746c7da4e9f22b28ca5d27ad5b0825
2022-08-14 01:14:53 +08:00

58 lines
1.1 KiB
Text

/**
* Return all elements of `array` that have a fuzzy match against `pattern`.
*/
export declare function simpleFilter(
pattern: string,
array: string[]
): string[];
/**
* Does `pattern` fuzzy match `inputString`?
*/
export declare function test(
pattern: string,
inputString: string
): boolean;
export interface MatchOptions {
pre?: string;
post?: string;
caseSensitive?: boolean;
}
export interface MatchResult {
rendered: string;
score: number;
}
/**
* If `pattern` matches `inputString`, wrap each matching character in `opts.pre`
* and `opts.post`. If no match, return null.
*/
export declare function match(
pattern: string,
inputString: string,
opts?: MatchOptions
): MatchResult;
export interface FilterOptions<T> {
pre?: string;
post?: string;
extract?(input: T): string;
}
export interface FilterResult<T> {
string: string;
score: number;
index: number;
original: T;
}
/**
* The normal entry point. Filters `arr` for matches against `pattern`.
*/
export declare function filter<T>(
pattern: string,
arr: T[],
opts?: FilterOptions<T>
): FilterResult<T>[];