1 |
|
2 | import { EventEmitter } from "events";
|
3 | import * as processors from "./lib/processors";
|
4 |
|
5 | export function parseString(str: convertableToString, callback: (err: Error | null, result: any) => void): void;
|
6 | export function parseString(
|
7 | str: convertableToString,
|
8 | options: ParserOptions,
|
9 | callback: (err: Error | null, result: any) => void,
|
10 | ): void;
|
11 | export function parseStringPromise(str: convertableToString, options?: ParserOptions): Promise<any>;
|
12 |
|
13 | export const defaults: {
|
14 | "0.1": Options;
|
15 | "0.2": OptionsV2;
|
16 | };
|
17 |
|
18 | export interface XmlDeclarationAttributes {
|
19 | version: string;
|
20 | encoding?: string | undefined;
|
21 | standalone?: boolean | undefined;
|
22 | }
|
23 |
|
24 | export interface RenderOptions {
|
25 | pretty?: boolean | undefined;
|
26 | indent?: string | undefined;
|
27 | newline?: string | undefined;
|
28 | }
|
29 |
|
30 | export class Builder {
|
31 | constructor(options?: BuilderOptions);
|
32 | buildObject(rootObj: any): string;
|
33 | }
|
34 |
|
35 | export class Parser extends EventEmitter {
|
36 | constructor(options?: ParserOptions);
|
37 | parseString(str: convertableToString, cb?: (error: Error | null, result: any) => void): void;
|
38 | parseStringPromise(str: convertableToString): Promise<any>;
|
39 | reset(): void;
|
40 | }
|
41 |
|
42 | export interface ParserOptions {
|
43 | attrkey?: string | undefined;
|
44 | charkey?: string | undefined;
|
45 | explicitCharkey?: boolean | undefined;
|
46 | trim?: boolean | undefined;
|
47 | normalizeTags?: boolean | undefined;
|
48 | normalize?: boolean | undefined;
|
49 | explicitRoot?: boolean | undefined;
|
50 | emptyTag?: (() => any) | string;
|
51 | explicitArray?: boolean | undefined;
|
52 | ignoreAttrs?: boolean | undefined;
|
53 | mergeAttrs?: boolean | undefined;
|
54 | validator?: Function | undefined;
|
55 | xmlns?: boolean | undefined;
|
56 | explicitChildren?: boolean | undefined;
|
57 | childkey?: string | undefined;
|
58 | preserveChildrenOrder?: boolean | undefined;
|
59 | charsAsChildren?: boolean | undefined;
|
60 | includeWhiteChars?: boolean | undefined;
|
61 | async?: boolean | undefined;
|
62 | strict?: boolean | undefined;
|
63 | attrNameProcessors?: Array<(name: string) => any> | undefined;
|
64 | attrValueProcessors?: Array<(value: string, name: string) => any> | undefined;
|
65 | tagNameProcessors?: Array<(name: string) => any> | undefined;
|
66 | valueProcessors?: Array<(value: string, name: string) => any> | undefined;
|
67 | chunkSize?: number | undefined;
|
68 | }
|
69 |
|
70 | export interface BuilderOptions {
|
71 | attrkey?: string | undefined;
|
72 | charkey?: string | undefined;
|
73 | rootName?: string | undefined;
|
74 | renderOpts?: RenderOptions | undefined;
|
75 | xmldec?: XmlDeclarationAttributes | undefined;
|
76 | doctype?: any;
|
77 | headless?: boolean | undefined;
|
78 | allowSurrogateChars?: boolean | undefined;
|
79 | cdata?: boolean | undefined;
|
80 | }
|
81 |
|
82 | export type Options = Omit<ParserOptions, "preserveChildrenOrder" | "chunkSize">;
|
83 | export type OptionsV2 = ParserOptions & BuilderOptions;
|
84 |
|
85 | export interface convertableToString {
|
86 | toString(): string;
|
87 | }
|
88 |
|
89 | export class ValidationError extends Error {
|
90 | constructor(message: string);
|
91 | }
|
92 |
|
93 | export { processors };
|