mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Expose provided processors living in xml2js/lib/processors
This commit is contained in:
parent
e7ee7e5060
commit
86e8ab2ca2
11
xml2js/index.d.ts
vendored
11
xml2js/index.d.ts
vendored
@ -3,7 +3,7 @@
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Jason McNeil <https://github.com/jasonrm>, Christopher Currens <https://github.com/ccurrens>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="./processors.d.ts" />
|
||||
|
||||
export = xml2js;
|
||||
|
||||
@ -29,8 +29,8 @@ declare namespace xml2js {
|
||||
interface Options {
|
||||
async?: boolean;
|
||||
attrkey?: string;
|
||||
attrNameProcessors?: [(name: string) => string];
|
||||
attrValueProcessors?: [(name: string) => string];
|
||||
attrNameProcessors?: [(name: string) => any];
|
||||
attrValueProcessors?: [(name: string) => any];
|
||||
charkey?: string;
|
||||
charsAsChildren?: boolean;
|
||||
childkey?: string;
|
||||
@ -45,10 +45,10 @@ declare namespace xml2js {
|
||||
normalize?: boolean;
|
||||
normalizeTags?: boolean;
|
||||
strict?: boolean;
|
||||
tagNameProcessors?: [(name: string) => string];
|
||||
tagNameProcessors?: [(name: string) => any];
|
||||
trim?: boolean;
|
||||
validator?: Function;
|
||||
valueProcessors?: [(name: string) => string];
|
||||
valueProcessors?: [(name: string) => any];
|
||||
xmlns?: boolean;
|
||||
}
|
||||
|
||||
@ -75,4 +75,3 @@ declare namespace xml2js {
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
xml2js/processors.d.ts
vendored
Normal file
11
xml2js/processors.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
declare module 'xml2js/lib/processors' {
|
||||
export function firstCharLowerCase(name: string): string;
|
||||
|
||||
export function normalize(name: string): string;
|
||||
|
||||
export function parseBooleans(name: string): boolean;
|
||||
|
||||
export function parseNumbers(name: string): number;
|
||||
|
||||
export function stripPrefix(name: string): string;
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
/// <reference types="node"/>
|
||||
|
||||
import xml2js = require('xml2js');
|
||||
import * as processors from 'xml2js/lib/processors';
|
||||
|
||||
xml2js.parseString('<root>Hello xml2js!</root>', (err: any, result: any) => { });
|
||||
|
||||
@ -32,6 +33,13 @@ xml2js.parseString('<root>Hello xml2js!</root>', {
|
||||
valueProcessors: undefined
|
||||
}, (err: any, result: any) => { });
|
||||
|
||||
xml2js.parseString('<root>Hello xml2js!</root>', {
|
||||
attrNameProcessors: [processors.firstCharLowerCase],
|
||||
attrValueProcessors: [processors.normalize],
|
||||
tagNameProcessors: [processors.stripPrefix],
|
||||
valueProcessors: [processors.parseBooleans, processors.parseNumbers]
|
||||
}, (err: any, result: any) => { });
|
||||
|
||||
var builder = new xml2js.Builder({
|
||||
renderOpts: {
|
||||
pretty: false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user