UNPKG

2.38 kBTypeScriptView Raw
1// Type definitions for node-xml2js
2// Project: https://github.com/Leonidas-from-XIV/node-xml2js
3// Definitions by: Michel Salib <https://github.com/michelsalib>, Jason McNeil <https://github.com/jasonrm>, Christopher Currens <https://github.com/ccurrens>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6
7
8export = xml2js;
9
10declare namespace xml2js {
11 function parseString(xml: convertableToString, callback: (err: any, result: any) => void): void;
12 function parseString(xml: convertableToString, options: OptionsV2, callback: (err: any, result: any) => void): void;
13
14 var defaults: {
15 '0.1': Options;
16 '0.2': OptionsV2;
17 }
18
19 class Builder {
20 constructor(options?: OptionsV2);
21 buildObject(rootObj: any): string;
22 }
23
24 class Parser {
25 constructor(options?: OptionsV2);
26 parseString(str: convertableToString, cb?: Function): void;
27 reset(): void;
28 }
29
30 interface Options {
31 async?: boolean;
32 attrkey?: string;
33 attrNameProcessors?: [(name: string) => string];
34 attrValueProcessors?: [(name: string) => string];
35 charkey?: string;
36 charsAsChildren?: boolean;
37 childkey?: string;
38 emptyTag?: any;
39 explicitArray?: boolean;
40 explicitCharkey?: boolean;
41 explicitChildren?: boolean;
42 explicitRoot?: boolean;
43 ignoreAttrs?: boolean;
44 includeWhiteChars?: boolean;
45 mergeAttrs?: boolean;
46 normalize?: boolean;
47 normalizeTags?: boolean;
48 strict?: boolean;
49 tagNameProcessors?: [(name: string) => string];
50 trim?: boolean;
51 validator?: Function;
52 valueProcessors?: [(name: string) => string];
53 xmlns?: boolean;
54 }
55
56 interface OptionsV2 extends Options {
57 preserveChildrenOrder?: boolean;
58 rootName?: string;
59 xmldec?: {
60 version: string;
61 encoding?: string;
62 standalone?: boolean;
63 };
64 doctype?: any;
65 renderOpts?: {
66 pretty?: boolean;
67 indent?: string;
68 newline?: string;
69 };
70 headless?: boolean;
71 chunkSize?: number;
72 cdata?: boolean;
73 }
74
75 interface convertableToString {
76 toString(): string;
77 }
78}
79