UNPKG

2.68 kBTypeScriptView Raw
1/// <reference types="node" />
2import type { InternalOptions } from './options.js';
3import type { AnyNode, Document, ParentNode } from 'domhandler';
4import type { BasicAcceptedElems } from './types.js';
5import * as Attributes from './api/attributes.js';
6import * as Traversing from './api/traversing.js';
7import * as Manipulation from './api/manipulation.js';
8import * as Css from './api/css.js';
9import * as Forms from './api/forms.js';
10declare type AttributesType = typeof Attributes;
11declare type TraversingType = typeof Traversing;
12declare type ManipulationType = typeof Manipulation;
13declare type CssType = typeof Css;
14declare type FormsType = typeof Forms;
15export 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}
64export interface Cheerio<T> extends AttributesType, TraversingType, ManipulationType, CssType, FormsType, Iterable<T> {
65 cheerio: '[cheerio object]';
66 splice: typeof Array.prototype.slice;
67}
68export {};
69//# sourceMappingURL=cheerio.d.ts.map
\No newline at end of file