static.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import type { CheerioAPI, Cheerio } from '.';
  2. import { Node, Document } from 'domhandler';
  3. import { CheerioOptions } from './options';
  4. /**
  5. * Renders the document.
  6. *
  7. * @param options - Options for the renderer.
  8. * @returns The rendered document.
  9. */
  10. export declare function html(this: CheerioAPI | void, options?: CheerioOptions): string;
  11. /**
  12. * Renders the document.
  13. *
  14. * @param dom - Element to render.
  15. * @param options - Options for the renderer.
  16. * @returns The rendered document.
  17. */
  18. export declare function html(this: CheerioAPI | void, dom?: string | ArrayLike<Node> | Node, options?: CheerioOptions): string;
  19. /**
  20. * Render the document as XML.
  21. *
  22. * @param dom - Element to render.
  23. * @returns THe rendered document.
  24. */
  25. export declare function xml(this: CheerioAPI, dom?: string | ArrayLike<Node> | Node): string;
  26. /**
  27. * Render the document as text.
  28. *
  29. * @param elements - Elements to render.
  30. * @returns The rendered document.
  31. */
  32. export declare function text(this: CheerioAPI | void, elements?: ArrayLike<Node>): string;
  33. /**
  34. * Parses a string into an array of DOM nodes. The `context` argument has no
  35. * meaning for Cheerio, but it is maintained for API compatibility with jQuery.
  36. *
  37. * @param data - Markup that will be parsed.
  38. * @param context - Will be ignored. If it is a boolean it will be used as the
  39. * value of `keepScripts`.
  40. * @param keepScripts - If false all scripts will be removed.
  41. * @returns The parsed DOM.
  42. * @alias Cheerio.parseHTML
  43. * @see {@link https://api.jquery.com/jQuery.parseHTML/}
  44. */
  45. export declare function parseHTML(this: CheerioAPI, data: string, context?: unknown | boolean, keepScripts?: boolean): Node[];
  46. export declare function parseHTML(this: CheerioAPI, data?: '' | null): null;
  47. /**
  48. * Sometimes you need to work with the top-level root element. To query it, you
  49. * can use `$.root()`.
  50. *
  51. * @example
  52. *
  53. * ```js
  54. * $.root().append('<ul id="vegetables"></ul>').html();
  55. * //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
  56. * ```
  57. *
  58. * @returns Cheerio instance wrapping the root node.
  59. * @alias Cheerio.root
  60. */
  61. export declare function root(this: CheerioAPI): Cheerio<Document>;
  62. /**
  63. * Checks to see if the `contained` DOM element is a descendant of the
  64. * `container` DOM element.
  65. *
  66. * @param container - Potential parent node.
  67. * @param contained - Potential child node.
  68. * @returns Indicates if the nodes contain one another.
  69. * @alias Cheerio.contains
  70. * @see {@link https://api.jquery.com/jQuery.contains/}
  71. */
  72. export declare function contains(container: Node, contained: Node): boolean;
  73. interface WritableArrayLike<T> extends ArrayLike<T> {
  74. length: number;
  75. [n: number]: T;
  76. }
  77. /**
  78. * $.merge().
  79. *
  80. * @param arr1 - First array.
  81. * @param arr2 - Second array.
  82. * @returns `arr1`, with elements of `arr2` inserted.
  83. * @alias Cheerio.merge
  84. * @see {@link https://api.jquery.com/jQuery.merge/}
  85. */
  86. export declare function merge<T>(arr1: WritableArrayLike<T>, arr2: ArrayLike<T>): ArrayLike<T> | undefined;
  87. export {};
  88. //# sourceMappingURL=static.d.ts.map