load.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /// <reference types="node" />
  2. import { CheerioOptions, InternalOptions } from './options.js';
  3. import * as staticMethods from './static.js';
  4. import { Cheerio } from './cheerio.js';
  5. import type { AnyNode, Document, Element } from 'domhandler';
  6. import type { SelectorType, BasicAcceptedElems } from './types.js';
  7. declare type StaticType = typeof staticMethods;
  8. /**
  9. * A querying function, bound to a document created from the provided markup.
  10. *
  11. * Also provides several helper methods for dealing with the document as a whole.
  12. */
  13. export interface CheerioAPI extends StaticType {
  14. /**
  15. * This selector method is the starting point for traversing and manipulating
  16. * the document. Like jQuery, it's the primary method for selecting elements
  17. * in the document.
  18. *
  19. * `selector` searches within the `context` scope which searches within the
  20. * `root` scope.
  21. *
  22. * @example
  23. *
  24. * ```js
  25. * $('.apple', '#fruits').text();
  26. * //=> Apple
  27. *
  28. * $('ul .pear').attr('class');
  29. * //=> pear
  30. *
  31. * $('li[class=orange]').html();
  32. * //=> Orange
  33. * ```
  34. *
  35. * @param selector - Either a selector to look for within the document, or the
  36. * contents of a new Cheerio instance.
  37. * @param context - Either a selector to look for within the root, or the
  38. * contents of the document to query.
  39. * @param root - Optional HTML document string.
  40. */
  41. <T extends AnyNode, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<AnyNode> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
  42. /**
  43. * The root the document was originally loaded with.
  44. *
  45. * @private
  46. */
  47. _root: Document;
  48. /**
  49. * The options the document was originally loaded with.
  50. *
  51. * @private
  52. */
  53. _options: InternalOptions;
  54. /** Mimic jQuery's prototype alias for plugin authors. */
  55. fn: typeof Cheerio.prototype;
  56. load: ReturnType<typeof getLoad>;
  57. }
  58. export declare function getLoad(parse: typeof Cheerio.prototype._parse, render: (dom: AnyNode | ArrayLike<AnyNode>, options: InternalOptions) => string): (content: string | AnyNode | AnyNode[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean) => CheerioAPI;
  59. export {};
  60. //# sourceMappingURL=load.d.ts.map