index.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { Parser, type ParserOptions } from "./Parser.js";
  2. export type { Handler, ParserOptions } from "./Parser.js";
  3. export { Parser } from "./Parser.js";
  4. import { type DomHandlerOptions, type ChildNode, type Element, type Document } from "domhandler";
  5. export { DomHandler, DomHandler as DefaultHandler, type DomHandlerOptions, } from "domhandler";
  6. export 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. */
  13. export 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. */
  24. export 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. */
  32. export 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. */
  41. export declare function createDomStream(callback: (error: Error | null, dom: ChildNode[]) => void, options?: Options, elementCallback?: (element: Element) => void): Parser;
  42. export { default as Tokenizer, type Callbacks as TokenizerCallbacks, QuoteType, } from "./Tokenizer.js";
  43. export * as ElementType from "domelementtype";
  44. import { type Feed } from "domutils";
  45. export { 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. */
  52. export declare function parseFeed(feed: string, options?: Options): Feed | null;
  53. export * as DomUtils from "domutils";
  54. //# sourceMappingURL=index.d.ts.map