diff --git a/xml2js/xml2js-tests.ts b/xml2js/xml2js-tests.ts index 45472c0aa..d0ed5e5b9 100644 --- a/xml2js/xml2js-tests.ts +++ b/xml2js/xml2js-tests.ts @@ -17,3 +17,10 @@ var outString = builder.buildObject({ }); var parser = new xml2js.Parser(); + +var v1Defaults = xml2js.defaults['0.1']; +v1Defaults.async = true; + +var v2Defaults = xml2js.defaults['0.2']; +v2Defaults.async = false; +v2Defaults.chunkSize = 20000; \ No newline at end of file diff --git a/xml2js/xml2js.d.ts b/xml2js/xml2js.d.ts index 0dc03add7..8e20ece75 100644 --- a/xml2js/xml2js.d.ts +++ b/xml2js/xml2js.d.ts @@ -1,6 +1,6 @@ // Type definitions for node-xml2js // Project: https://github.com/Leonidas-from-XIV/node-xml2js -// Definitions by: Michel Salib , Jason McNeil +// Definitions by: Michel Salib , Jason McNeil , Christopher Currens // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module 'xml2js' { @@ -11,6 +11,11 @@ declare module 'xml2js' { function parseString(xml: string, callback: (err: any, result: any) => void): void; function parseString(xml: string, options: Options, callback: (err: any, result: any) => void): void; + var defaults: { + '0.1': Options; + '0.2': OptionsV2; + } + class Builder { constructor(options?: BuilderOptions); buildObject(rootObj: any): string; @@ -50,7 +55,8 @@ declare module 'xml2js' { interface Options { async?: boolean; attrkey?: string; - attrNameProcessors?: (name: string) => string; + attrNameProcessors?: [(name: string) => string]; + attrValueProcessors?: [(name: string) => string]; charkey?: string; charsAsChildren?: boolean; childkey?: string; @@ -67,7 +73,27 @@ declare module 'xml2js' { tagNameProcessors?: [(name: string) => string]; trim?: boolean; validator?: Function; + valueProcessors?: [(name: string) => string]; xmlns?: boolean; } + + interface OptionsV2 extends Options { + preserveChildrenOrder?: boolean; + rootName?: string; + xmldec?: { + version: string; + encoding?: string; + standalone?: boolean; + }; + doctype?: any; + renderOpts?: { + pretty?: boolean; + indent?: string; + newline?: string; + }; + headless?: boolean; + chunkSize?: number; + cdata?: boolean; + } } }