mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Add Builder support/options to xml2js
This commit is contained in:
@@ -5,3 +5,13 @@ import xml2js = require('xml2js');
|
||||
xml2js.parseString("<root>Hello xml2js!</root>", (err: any, result: any) => { });
|
||||
|
||||
xml2js.parseString("<root>Hello xml2js!</root>", {trim: true}, (err: any, result: any) => { });
|
||||
|
||||
var builder = new xml2js.Builder({
|
||||
renderOpts: {
|
||||
pretty: false
|
||||
}
|
||||
});
|
||||
|
||||
var outString = builder.buildObject({
|
||||
'hello': 'xml2js!'
|
||||
});
|
||||
|
||||
Vendored
+53
-24
@@ -1,6 +1,6 @@
|
||||
// Type definitions for node-xml2js
|
||||
// Project: https://github.com/Leonidas-from-XIV/node-xml2js
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Jason McNeil <https://github.com/jasonrm>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'xml2js' {
|
||||
@@ -8,29 +8,58 @@ declare module 'xml2js' {
|
||||
export = xml2js;
|
||||
|
||||
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;
|
||||
function parseString(xml: string, callback: (err: any, result: any) => void): void;
|
||||
function parseString(xml: string, options: Options, callback: (err: any, result: any) => void): void;
|
||||
|
||||
interface Options {
|
||||
attrkey?: string;
|
||||
charkey?: string;
|
||||
explicitCharkey?: boolean;
|
||||
trim?: boolean;
|
||||
normalizeTags?: boolean;
|
||||
normalize?: boolean;
|
||||
explicitRoot?: boolean;
|
||||
emptyTag?: any;
|
||||
explicitArray?: boolean;
|
||||
ignoreAttrs?: boolean;
|
||||
mergeAttrs?: boolean;
|
||||
validator?: Function;
|
||||
xmlns?: boolean;
|
||||
explicitChildren?: boolean;
|
||||
charsAsChildren?: boolean;
|
||||
async?: boolean;
|
||||
strict?: boolean;
|
||||
attrNameProcessors?: (name: string) => string;
|
||||
tagNameProcessors?: (name: string) => string;
|
||||
}
|
||||
class Builder {
|
||||
constructor(options?: BuilderOptions);
|
||||
buildObject(rootObj: any): string;
|
||||
}
|
||||
|
||||
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;
|
||||
attrNameProcessors?: (name: string) => string;
|
||||
charkey?: string;
|
||||
charsAsChildren?: boolean;
|
||||
childkey?: string;
|
||||
emptyTag?: any;
|
||||
explicitArray?: boolean;
|
||||
explicitCharkey?: boolean;
|
||||
explicitChildren?: boolean;
|
||||
explicitRoot?: boolean;
|
||||
ignoreAttrs?: boolean;
|
||||
mergeAttrs?: boolean;
|
||||
normalize?: boolean;
|
||||
normalizeTags?: boolean;
|
||||
strict?: boolean;
|
||||
tagNameProcessors?: (name: string) => string;
|
||||
trim?: boolean;
|
||||
validator?: Function;
|
||||
xmlns?: boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user