diff --git a/xml2js/index.d.ts b/xml2js/index.d.ts
index e9d4e12ad0..0e180f7ba8 100644
--- a/xml2js/index.d.ts
+++ b/xml2js/index.d.ts
@@ -9,7 +9,7 @@ export = xml2js;
declare namespace 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;
+ function parseString(xml: string, options: OptionsV2, callback: (err: any, result: any) => void): void;
var defaults: {
'0.1': Options;
@@ -17,41 +17,15 @@ declare namespace xml2js {
}
class Builder {
- constructor(options?: BuilderOptions);
+ constructor(options?: OptionsV2);
buildObject(rootObj: any): string;
}
class Parser {
- constructor(options?: Options);
- processAsync(): any;
- assignOrPush(obj: any, key: string, newValue: any): any;
- reset(): any;
+ constructor(options?: OptionsV2);
parseString(str: string, cb?: Function): void;
}
- interface RenderOptions {
- indent?: string;
- newline?: string;
- pretty?: boolean;
- }
-
- interface XMLDeclarationOptions {
- encoding?: string;
- standalone?: boolean;
- version?: string;
- }
-
- interface BuilderOptions {
- doctype?: any;
- headless?: boolean;
- indent?: string;
- newline?: string;
- pretty?: boolean;
- renderOpts?: RenderOptions;
- rootName?: string;
- xmldec?: XMLDeclarationOptions;
- }
-
interface Options {
async?: boolean;
attrkey?: string;
@@ -66,6 +40,7 @@ declare namespace xml2js {
explicitChildren?: boolean;
explicitRoot?: boolean;
ignoreAttrs?: boolean;
+ includeWhiteChars?: boolean;
mergeAttrs?: boolean;
normalize?: boolean;
normalizeTags?: boolean;
@@ -96,3 +71,4 @@ declare namespace xml2js {
cdata?: boolean;
}
}
+
diff --git a/xml2js/tsconfig.json b/xml2js/tsconfig.json
index 61e4e5e52f..8e23bd3395 100644
--- a/xml2js/tsconfig.json
+++ b/xml2js/tsconfig.json
@@ -3,7 +3,7 @@
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
- "strictNullChecks": false,
+ "strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -16,4 +16,4 @@
"index.d.ts",
"xml2js-tests.ts"
]
-}
\ No newline at end of file
+}
diff --git a/xml2js/xml2js-tests.ts b/xml2js/xml2js-tests.ts
index 3e3981156e..38306d9bb4 100644
--- a/xml2js/xml2js-tests.ts
+++ b/xml2js/xml2js-tests.ts
@@ -1,9 +1,35 @@
import xml2js = require('xml2js');
-xml2js.parseString("Hello xml2js!", (err: any, result: any) => { });
+xml2js.parseString('Hello xml2js!', (err: any, result: any) => { });
-xml2js.parseString("Hello xml2js!", {trim: true}, (err: any, result: any) => { });
+xml2js.parseString('Hello xml2js!', {trim: true}, (err: any, result: any) => { });
+
+xml2js.parseString('Hello xml2js!', {
+ attrkey: '$',
+ charkey: '_',
+ explicitCharkey: false,
+ trim: false,
+ normalizeTags: false,
+ explicitRoot: true,
+ emptyTag: '',
+ explicitArray: true,
+ ignoreAttrs: false,
+ mergeAttrs: false,
+ validator: undefined,
+ xmlns: false,
+ explicitChildren: false,
+ childkey: '$$',
+ preserveChildrenOrder: false,
+ charsAsChildren: false,
+ includeWhiteChars: false,
+ async: false,
+ strict: true,
+ attrNameProcessors: undefined,
+ attrValueProcessors: undefined,
+ tagNameProcessors: undefined,
+ valueProcessors: undefined
+}, (err: any, result: any) => { });
var builder = new xml2js.Builder({
renderOpts: {
@@ -11,6 +37,23 @@ var builder = new xml2js.Builder({
}
});
+var builder = new xml2js.Builder({
+ rootName: 'root',
+ renderOpts: {
+ pretty: true,
+ indent: ' ',
+ newline: '\n'
+ },
+ xmldec: {
+ version: '1.0',
+ encoding: 'UTF-8',
+ standalone: true
+ },
+ doctype: { ext: 'hello.dtd' },
+ headless: false,
+ cdata: false
+});
+
var outString = builder.buildObject({
'hello': 'xml2js!'
});
@@ -22,4 +65,5 @@ v1Defaults.async = true;
var v2Defaults = xml2js.defaults['0.2'];
v2Defaults.async = false;
-v2Defaults.chunkSize = 20000;
\ No newline at end of file
+v2Defaults.chunkSize = 20000;
+