UNPKG

2.24 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: string, callback: (err: any, result: any) => void): void;
12 function parseString(xml: string, 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: string, cb?: Function): void;
27 }
28
29 interface Options {
30 async?: boolean;
31 attrkey?: string;
32 attrNameProcessors?: [(name: string) => string];
33 attrValueProcessors?: [(name: string) => string];
34 charkey?: string;
35 charsAsChildren?: boolean;
36 childkey?: string;
37 emptyTag?: any;
38 explicitArray?: boolean;
39 explicitCharkey?: boolean;
40 explicitChildren?: boolean;
41 explicitRoot?: boolean;
42 ignoreAttrs?: boolean;
43 includeWhiteChars?: boolean;
44 mergeAttrs?: boolean;
45 normalize?: boolean;
46 normalizeTags?: boolean;
47 strict?: boolean;
48 tagNameProcessors?: [(name: string) => string];
49 trim?: boolean;
50 validator?: Function;
51 valueProcessors?: [(name: string) => string];
52 xmlns?: boolean;
53 }
54
55 interface OptionsV2 extends Options {
56 preserveChildrenOrder?: boolean;
57 rootName?: string;
58 xmldec?: {
59 version: string;
60 encoding?: string;
61 standalone?: boolean;
62 };
63 doctype?: any;
64 renderOpts?: {
65 pretty?: boolean;
66 indent?: string;
67 newline?: string;
68 };
69 headless?: boolean;
70 chunkSize?: number;
71 cdata?: boolean;
72 }
73}
74