UNPKG

2.07 kBTypeScriptView Raw
1import { Node, Element } from "domhandler";
2/**
3 * Search a node and its children for nodes passing a test function.
4 *
5 * @param test Function to test nodes on.
6 * @param element Element to search. Will be included in the result set if it matches.
7 * @param recurse Also consider child nodes.
8 * @param limit Maximum number of nodes to return.
9 */
10export declare function filter(test: (elem: Node) => boolean, node: Node | Node[], recurse?: boolean, limit?: number): Node[];
11/**
12 * Like `filter`, but only works on an array of nodes.
13 *
14 * @param test Function to test nodes on.
15 * @param nodes Array of nodes to search.
16 * @param recurse Also consider child nodes.
17 * @param limit Maximum number of nodes to return.
18 */
19export declare function find(test: (elem: Node) => boolean, nodes: Node[], recurse: boolean, limit: number): Node[];
20/**
21 * Finds the first element inside of an array that matches a test function.
22 *
23 * @param test Function to test nodes on.
24 * @param nodes Array of nodes to search.
25 */
26export declare function findOneChild(test: (elem: Node) => boolean, nodes: Node[]): Node | undefined;
27/**
28 * Finds one element in a tree that passes a test.
29 *
30 * @param test Function to test nodes on.
31 * @param nodes Array of nodes to search.
32 * @param recurse Also consider child nodes.
33 */
34export declare function findOne(test: (elem: Element) => boolean, nodes: Node[], recurse?: boolean): Element | null;
35/**
36 * Returns whether a tree of nodes contains at least one node passing a test.
37 *
38 * @param test Function to test nodes on.
39 * @param nodes Array of nodes to search.
40 */
41export declare function existsOne(test: (elem: Element) => boolean, nodes: Node[]): boolean;
42/**
43 * Search and array of nodes and its children for nodes passing a test function.
44 *
45 * Same as `find`, only with less options, leading to reduced complexity.
46 *
47 * @param test Function to test nodes on.
48 * @param nodes Array of nodes to search.
49 */
50export declare function findAll(test: (elem: Element) => boolean, nodes: Node[]): Element[];
51//# sourceMappingURL=querying.d.ts.map
\No newline at end of file