cheerio.d.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /// <reference types="node" />
  2. import type { InternalOptions } from './options.js';
  3. import type { AnyNode, Document, ParentNode } from 'domhandler';
  4. import type { BasicAcceptedElems } from './types.js';
  5. import * as Attributes from './api/attributes.js';
  6. import * as Traversing from './api/traversing.js';
  7. import * as Manipulation from './api/manipulation.js';
  8. import * as Css from './api/css.js';
  9. import * as Forms from './api/forms.js';
  10. declare type AttributesType = typeof Attributes;
  11. declare type TraversingType = typeof Traversing;
  12. declare type ManipulationType = typeof Manipulation;
  13. declare type CssType = typeof Css;
  14. declare type FormsType = typeof Forms;
  15. export declare abstract class Cheerio<T> implements ArrayLike<T> {
  16. length: number;
  17. [index: number]: T;
  18. options: InternalOptions;
  19. /**
  20. * The root of the document. Can be set by using the `root` argument of the constructor.
  21. *
  22. * @private
  23. */
  24. _root: Cheerio<Document> | null;
  25. /**
  26. * Instance of cheerio. Methods are specified in the modules. Usage of this
  27. * constructor is not recommended. Please use `$.load` instead.
  28. *
  29. * @private
  30. * @param elements - The new selection.
  31. * @param root - Sets the root node.
  32. * @param options - Options for the instance.
  33. */
  34. constructor(elements: ArrayLike<T> | undefined, root: Cheerio<Document> | null, options: InternalOptions);
  35. prevObject: Cheerio<any> | undefined;
  36. /**
  37. * Make a cheerio object.
  38. *
  39. * @private
  40. * @param dom - The contents of the new object.
  41. * @param context - The context of the new object.
  42. * @returns The new cheerio object.
  43. */
  44. abstract _make<T>(dom: ArrayLike<T> | T | string, context?: BasicAcceptedElems<AnyNode>): Cheerio<T>;
  45. /**
  46. * Parses some content.
  47. *
  48. * @private
  49. * @param content - Content to parse.
  50. * @param options - Options for parsing.
  51. * @param isDocument - Allows parser to be switched to fragment mode.
  52. * @returns A document containing the `content`.
  53. */
  54. abstract _parse(content: string | Document | AnyNode | AnyNode[] | Buffer, options: InternalOptions, isDocument: boolean, context: ParentNode | null): Document;
  55. /**
  56. * Render an element or a set of elements.
  57. *
  58. * @private
  59. * @param dom - DOM to render.
  60. * @returns The rendered DOM.
  61. */
  62. abstract _render(dom: AnyNode | ArrayLike<AnyNode>): string;
  63. }
  64. export interface Cheerio<T> extends AttributesType, TraversingType, ManipulationType, CssType, FormsType, Iterable<T> {
  65. cheerio: '[cheerio object]';
  66. splice: typeof Array.prototype.slice;
  67. }
  68. export {};
  69. //# sourceMappingURL=cheerio.d.ts.map