UNPKG

2.51 kBTypeScriptView Raw
1export interface ElementCompact {
2 [key: string]: any
3 _declaration?: {
4 _attributes?: {
5 version?: string | number
6 encoding?: string | number
7 }
8 }
9 _instruction?: {
10 [key: string]: string
11 }
12 _attributes?: {
13 [key: string]: string | number
14 }
15 _cdata?: string
16 _doctype?: string
17 _comment?: string
18 _text?: string | number
19}
20
21export interface Element {
22 declaration?: {
23 attributes?: {
24 version: string | number
25 encoding: string | number
26 }
27 }
28 instruction?: string
29 attributes?: {
30 [key: string]: string | number
31 }
32 cdata?: string
33 doctype?: string
34 comment?: string
35 text?: string | number | boolean
36 type?: string
37 name?: string
38 elements?: Array<Element>
39}
40
41declare namespace Options {
42 interface XML2JSON extends XML2JS {
43 spaces?: number | string
44 }
45
46 interface XML2JS extends ChangingKeyNames, IgnoreOptions {
47 compact?: boolean
48 trim?: boolean
49 sanitize?: boolean
50 nativeType?: boolean
51 addParent?: boolean
52 alwaysArray?: boolean
53 alwaysChildren?: boolean
54 instructionHasAttributes?: boolean
55 captureSpacesBetweenElements?: boolean
56 }
57
58 interface JS2XML extends ChangingKeyNames, IgnoreOptions {
59 spaces?: number | string
60 compact?: boolean
61 indentText?: boolean
62 indentCdata?: boolean
63 indentAttributes?: boolean
64 indentInstruction?: boolean
65 fullTagEmptyElement?: boolean
66 }
67
68 interface IgnoreOptions {
69 ignoreDeclaration?: boolean
70 ignoreInstruction?: boolean
71 ignoreAttributes?: boolean
72 ignoreComment?: boolean
73 ignoreCdata?: boolean
74 ignoreDoctype?: boolean
75 ignoreText?: boolean
76 }
77
78 interface ChangingKeyNames {
79 declarationKey?: string
80 instructionKey?: string
81 attributesKey?: string
82 textKey?: string
83 cdataKey?: string
84 doctypeKey?: string
85 commentKey?: string
86 parentKey?: string
87 typeKey?: string
88 nameKey?: string
89 elementsKey?: string
90 }
91}
92
93export function js2xml(obj: Element | ElementCompact, options?: Options.JS2XML): string;
94export function json2xml(json: string, options?: Options.JS2XML): string;
95export function xml2json(xml: string, options?: Options.XML2JSON): string;
96export function xml2js(xml: string, options?: Options.XML2JS): any;