querying.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { 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 node Node 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. * @returns All nodes passing `test`.
  10. */
  11. export declare function filter(test: (elem: Node) => boolean, node: Node | Node[], recurse?: boolean, limit?: number): Node[];
  12. /**
  13. * Search an array of node and its children for nodes passing a test function.
  14. *
  15. * @param test Function to test nodes on.
  16. * @param nodes Array of nodes to search.
  17. * @param recurse Also consider child nodes.
  18. * @param limit Maximum number of nodes to return.
  19. * @returns All nodes passing `test`.
  20. */
  21. export declare function find(test: (elem: Node) => boolean, nodes: Node[], recurse: boolean, limit: number): Node[];
  22. /**
  23. * Finds the first element inside of an array that matches a test function.
  24. *
  25. * @param test Function to test nodes on.
  26. * @param nodes Array of nodes to search.
  27. * @returns The first node in the array that passes `test`.
  28. */
  29. export declare function findOneChild(test: (elem: Node) => boolean, nodes: Node[]): Node | undefined;
  30. /**
  31. * Finds one element in a tree that passes a test.
  32. *
  33. * @param test Function to test nodes on.
  34. * @param nodes Array of nodes to search.
  35. * @param recurse Also consider child nodes.
  36. * @returns The first child node that passes `test`.
  37. */
  38. export declare function findOne(test: (elem: Element) => boolean, nodes: Node[], recurse?: boolean): Element | null;
  39. /**
  40. * @param test Function to test nodes on.
  41. * @param nodes Array of nodes to search.
  42. * @returns Whether a tree of nodes contains at least one node passing a test.
  43. */
  44. export declare function existsOne(test: (elem: Element) => boolean, nodes: Node[]): boolean;
  45. /**
  46. * Search and array of nodes and its children for nodes passing a test function.
  47. *
  48. * Same as `find`, only with less options, leading to reduced complexity.
  49. *
  50. * @param test Function to test nodes on.
  51. * @param nodes Array of nodes to search.
  52. * @returns All nodes passing `test`.
  53. */
  54. export declare function findAll(test: (elem: Element) => boolean, nodes: Node[]): Element[];
  55. //# sourceMappingURL=querying.d.ts.map