2022-09-03 17:12:22 +10:00
|
|
|
import { Element, AnyNode } from "domhandler";
|
2021-11-24 19:46:47 +11:00
|
|
|
/**
|
|
|
|
* Search a node and its children for nodes passing a test function.
|
|
|
|
*
|
2022-09-03 17:12:22 +10:00
|
|
|
* @category Querying
|
2021-11-24 19:46:47 +11:00
|
|
|
* @param test Function to test nodes on.
|
|
|
|
* @param node Node to search. Will be included in the result set if it matches.
|
|
|
|
* @param recurse Also consider child nodes.
|
|
|
|
* @param limit Maximum number of nodes to return.
|
|
|
|
* @returns All nodes passing `test`.
|
|
|
|
*/
|
2022-09-03 17:12:22 +10:00
|
|
|
export declare function filter(test: (elem: AnyNode) => boolean, node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
|
2021-11-24 19:46:47 +11:00
|
|
|
/**
|
|
|
|
* Search an array of node and its children for nodes passing a test function.
|
|
|
|
*
|
2022-09-03 17:12:22 +10:00
|
|
|
* @category Querying
|
2021-11-24 19:46:47 +11:00
|
|
|
* @param test Function to test nodes on.
|
|
|
|
* @param nodes Array of nodes to search.
|
|
|
|
* @param recurse Also consider child nodes.
|
|
|
|
* @param limit Maximum number of nodes to return.
|
|
|
|
* @returns All nodes passing `test`.
|
|
|
|
*/
|
2022-09-03 17:12:22 +10:00
|
|
|
export declare function find(test: (elem: AnyNode) => boolean, nodes: AnyNode[], recurse: boolean, limit: number): AnyNode[];
|
2021-11-24 19:46:47 +11:00
|
|
|
/**
|
|
|
|
* Finds the first element inside of an array that matches a test function.
|
|
|
|
*
|
2022-09-03 17:12:22 +10:00
|
|
|
* @category Querying
|
2021-11-24 19:46:47 +11:00
|
|
|
* @param test Function to test nodes on.
|
|
|
|
* @param nodes Array of nodes to search.
|
|
|
|
* @returns The first node in the array that passes `test`.
|
2022-09-03 17:12:22 +10:00
|
|
|
* @deprecated Use `Array.prototype.find` directly.
|
2021-11-24 19:46:47 +11:00
|
|
|
*/
|
2022-09-03 17:12:22 +10:00
|
|
|
export declare function findOneChild<T>(test: (elem: T) => boolean, nodes: T[]): T | undefined;
|
2021-11-24 19:46:47 +11:00
|
|
|
/**
|
|
|
|
* Finds one element in a tree that passes a test.
|
|
|
|
*
|
2022-09-03 17:12:22 +10:00
|
|
|
* @category Querying
|
2021-11-24 19:46:47 +11:00
|
|
|
* @param test Function to test nodes on.
|
|
|
|
* @param nodes Array of nodes to search.
|
|
|
|
* @param recurse Also consider child nodes.
|
|
|
|
* @returns The first child node that passes `test`.
|
|
|
|
*/
|
2022-09-03 17:12:22 +10:00
|
|
|
export declare function findOne(test: (elem: Element) => boolean, nodes: AnyNode[], recurse?: boolean): Element | null;
|
2021-11-24 19:46:47 +11:00
|
|
|
/**
|
2022-09-03 17:12:22 +10:00
|
|
|
* @category Querying
|
2021-11-24 19:46:47 +11:00
|
|
|
* @param test Function to test nodes on.
|
|
|
|
* @param nodes Array of nodes to search.
|
2022-09-03 17:12:22 +10:00
|
|
|
* @returns Whether a tree of nodes contains at least one node passing the test.
|
2021-11-24 19:46:47 +11:00
|
|
|
*/
|
2022-09-03 17:12:22 +10:00
|
|
|
export declare function existsOne(test: (elem: Element) => boolean, nodes: AnyNode[]): boolean;
|
2021-11-24 19:46:47 +11:00
|
|
|
/**
|
2022-09-03 17:12:22 +10:00
|
|
|
* Search and array of nodes and its children for elements passing a test function.
|
2021-11-24 19:46:47 +11:00
|
|
|
*
|
2022-09-03 17:12:22 +10:00
|
|
|
* Same as `find`, but limited to elements and with less options, leading to reduced complexity.
|
2021-11-24 19:46:47 +11:00
|
|
|
*
|
2022-09-03 17:12:22 +10:00
|
|
|
* @category Querying
|
2021-11-24 19:46:47 +11:00
|
|
|
* @param test Function to test nodes on.
|
|
|
|
* @param nodes Array of nodes to search.
|
|
|
|
* @returns All nodes passing `test`.
|
|
|
|
*/
|
2022-09-03 17:12:22 +10:00
|
|
|
export declare function findAll(test: (elem: Element) => boolean, nodes: AnyNode[]): Element[];
|
2021-11-24 19:46:47 +11:00
|
|
|
//# sourceMappingURL=querying.d.ts.map
|