UNPKG

2.83 kBTypeScriptView Raw
1import { Parser, type ParserOptions } from "./Parser.js";
2export type { Handler, ParserOptions } from "./Parser.js";
3export { Parser } from "./Parser.js";
4import { type DomHandlerOptions, type ChildNode, type Element, type Document } from "domhandler";
5export { DomHandler, DomHandler as DefaultHandler, type DomHandlerOptions, } from "domhandler";
6export type Options = ParserOptions & DomHandlerOptions;
7/**
8 * Parses the data, returns the resulting document.
9 *
10 * @param data The data that should be parsed.
11 * @param options Optional options for the parser and DOM handler.
12 */
13export declare function parseDocument(data: string, options?: Options): Document;
14/**
15 * Parses data, returns an array of the root nodes.
16 *
17 * Note that the root nodes still have a `Document` node as their parent.
18 * Use `parseDocument` to get the `Document` node instead.
19 *
20 * @param data The data that should be parsed.
21 * @param options Optional options for the parser and DOM handler.
22 * @deprecated Use `parseDocument` instead.
23 */
24export declare function parseDOM(data: string, options?: Options): ChildNode[];
25/**
26 * Creates a parser instance, with an attached DOM handler.
27 *
28 * @param callback A callback that will be called once parsing has been completed, with the resulting document.
29 * @param options Optional options for the parser and DOM handler.
30 * @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.
31 */
32export declare function createDocumentStream(callback: (error: Error | null, document: Document) => void, options?: Options, elementCallback?: (element: Element) => void): Parser;
33/**
34 * Creates a parser instance, with an attached DOM handler.
35 *
36 * @param callback A callback that will be called once parsing has been completed, with an array of root nodes.
37 * @param options Optional options for the parser and DOM handler.
38 * @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.
39 * @deprecated Use `createDocumentStream` instead.
40 */
41export declare function createDomStream(callback: (error: Error | null, dom: ChildNode[]) => void, options?: Options, elementCallback?: (element: Element) => void): Parser;
42export { default as Tokenizer, type Callbacks as TokenizerCallbacks, QuoteType, } from "./Tokenizer.js";
43export * as ElementType from "domelementtype";
44import { type Feed } from "domutils";
45export { getFeed, type Feed } from "domutils";
46/**
47 * Parse a feed.
48 *
49 * @param feed The feed that should be parsed, as a string.
50 * @param options Optionally, options for parsing. When using this, you should set `xmlMode` to `true`.
51 */
52export declare function parseFeed(feed: string, options?: Options): Feed | null;
53export * as DomUtils from "domutils";
54//# sourceMappingURL=index.d.ts.map
\No newline at end of file