-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matcher.ts
38 lines (34 loc) · 1001 Bytes
/
matcher.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type { Denops } from "@denops/std";
import type { Detail, DetailUnit, IdItem } from "./item.ts";
/**
* Parameters for matching items.
*/
export type MatchParams<T extends Detail> = {
/**
* User input query for filtering.
*/
readonly query: string;
/**
* Array of items to match against the query.
*/
readonly items: readonly IdItem<T>[];
};
/**
* Matcher that filters items based on user input.
*/
export type Matcher<T extends Detail = DetailUnit> = {
__phantom?: (_: T) => void; // This is required for type constraint.
/**
* Matches items against the provided query.
*
* @param denops - The Denops instance.
* @param params - Parameters for matching items.
* @param options - Additional options, including an abort signal.
* @returns An async iterator over matched `IdItem` elements.
*/
match<V extends T>(
denops: Denops,
params: MatchParams<V>,
options: { signal?: AbortSignal },
): AsyncIterableIterator<IdItem<V>>;
};