querying.d.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Element, AnyNode } from "domhandler";
  2. /**
  3. * Search a node and its children for nodes passing a test function.
  4. *
  5. * @category Querying
  6. * @param test Function to test nodes on.
  7. * @param node Node to search. Will be included in the result set if it matches.
  8. * @param recurse Also consider child nodes.
  9. * @param limit Maximum number of nodes to return.
  10. * @returns All nodes passing `test`.
  11. */
  12. export declare function filter(test: (elem: AnyNode) => boolean, node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
  13. /**
  14. * Search an array of node and its children for nodes passing a test function.
  15. *
  16. * @category Querying
  17. * @param test Function to test nodes on.
  18. * @param nodes Array of nodes to search.
  19. * @param recurse Also consider child nodes.
  20. * @param limit Maximum number of nodes to return.
  21. * @returns All nodes passing `test`.
  22. */
  23. export declare function find(test: (elem: AnyNode) => boolean, nodes: AnyNode[], recurse: boolean, limit: number): AnyNode[];
  24. /**
  25. * Finds the first element inside of an array that matches a test function.
  26. *
  27. * @category Querying
  28. * @param test Function to test nodes on.
  29. * @param nodes Array of nodes to search.
  30. * @returns The first node in the array that passes `test`.
  31. * @deprecated Use `Array.prototype.find` directly.
  32. */
  33. export declare function findOneChild<T>(test: (elem: T) => boolean, nodes: T[]): T | undefined;
  34. /**
  35. * Finds one element in a tree that passes a test.
  36. *
  37. * @category Querying
  38. * @param test Function to test nodes on.
  39. * @param nodes Array of nodes to search.
  40. * @param recurse Also consider child nodes.
  41. * @returns The first child node that passes `test`.
  42. */
  43. export declare function findOne(test: (elem: Element) => boolean, nodes: AnyNode[], recurse?: boolean): Element | null;
  44. /**
  45. * @category Querying
  46. * @param test Function to test nodes on.
  47. * @param nodes Array of nodes to search.
  48. * @returns Whether a tree of nodes contains at least one node passing the test.
  49. */
  50. export declare function existsOne(test: (elem: Element) => boolean, nodes: AnyNode[]): boolean;
  51. /**
  52. * Search and array of nodes and its children for elements passing a test function.
  53. *
  54. * Same as `find`, but limited to elements and with less options, leading to reduced complexity.
  55. *
  56. * @category Querying
  57. * @param test Function to test nodes on.
  58. * @param nodes Array of nodes to search.
  59. * @returns All nodes passing `test`.
  60. */
  61. export declare function findAll(test: (elem: Element) => boolean, nodes: AnyNode[]): Element[];
  62. //# sourceMappingURL=querying.d.ts.map