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