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(str: convertableToString, options: OptionsV2, callback: (err: Error, result: any) => void): void;
|
19 | export function parseStringPromise(str: convertableToString, options?: OptionsV2): Promise<any>;
|
20 |
|
21 | export const defaults: {
|
22 | '0.1': Options;
|
23 | '0.2': OptionsV2;
|
24 | };
|
25 |
|
26 | export class Builder {
|
27 | constructor(options?: OptionsV2);
|
28 | buildObject(rootObj: any): string;
|
29 | }
|
30 |
|
31 | export class Parser extends EventEmitter {
|
32 | constructor(options?: OptionsV2);
|
33 | parseString(str: convertableToString, cb?: Function): void;
|
34 | parseStringPromise(str: convertableToString): Promise<any>;
|
35 | reset(): void;
|
36 | }
|
37 |
|
38 | export interface Options {
|
39 | async?: boolean;
|
40 | attrkey?: string;
|
41 | attrNameProcessors?: Array<(name: string) => any>;
|
42 | attrValueProcessors?: Array<(value: string, name: string) => any>;
|
43 | charkey?: string;
|
44 | charsAsChildren?: boolean;
|
45 | childkey?: string;
|
46 | emptyTag?: any;
|
47 | explicitArray?: boolean;
|
48 | explicitCharkey?: boolean;
|
49 | explicitChildren?: boolean;
|
50 | explicitRoot?: boolean;
|
51 | ignoreAttrs?: boolean;
|
52 | includeWhiteChars?: boolean;
|
53 | mergeAttrs?: boolean;
|
54 | normalize?: boolean;
|
55 | normalizeTags?: boolean;
|
56 | strict?: boolean;
|
57 | tagNameProcessors?: Array<(name: string) => any>;
|
58 | trim?: boolean;
|
59 | validator?: Function;
|
60 | valueProcessors?: Array<(value: string, name: string) => any>;
|
61 | xmlns?: boolean;
|
62 | }
|
63 |
|
64 | export interface OptionsV2 extends Options {
|
65 | preserveChildrenOrder?: boolean;
|
66 | rootName?: string;
|
67 | xmldec?: {
|
68 | version: string;
|
69 | encoding?: string;
|
70 | standalone?: boolean;
|
71 | };
|
72 | doctype?: any;
|
73 | renderOpts?: {
|
74 | pretty?: boolean;
|
75 | indent?: string;
|
76 | newline?: string;
|
77 | };
|
78 | headless?: boolean;
|
79 | chunkSize?: number;
|
80 | cdata?: boolean;
|
81 | }
|
82 |
|
83 | export interface convertableToString {
|
84 | toString(): string;
|
85 | }
|
86 |
|
87 | export { processors };
|