mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Merge pull request #12287 from horiuchi/update-xml2js
feat: update xml2js type definition
This commit is contained in:
commit
33ae2bd878
34
xml2js/index.d.ts
vendored
34
xml2js/index.d.ts
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,35 @@
|
||||
|
||||
import xml2js = require('xml2js');
|
||||
|
||||
xml2js.parseString("<root>Hello xml2js!</root>", (err: any, result: any) => { });
|
||||
xml2js.parseString('<root>Hello xml2js!</root>', (err: any, result: any) => { });
|
||||
|
||||
xml2js.parseString("<root>Hello xml2js!</root>", {trim: true}, (err: any, result: any) => { });
|
||||
xml2js.parseString('<root>Hello xml2js!</root>', {trim: true}, (err: any, result: any) => { });
|
||||
|
||||
xml2js.parseString('<root>Hello xml2js!</root>', {
|
||||
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;
|
||||
v2Defaults.chunkSize = 20000;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user