[xml2js] Add processors to the main xml2js object

This commit is contained in:
Behind The Math
2017-10-26 22:42:00 -04:00
parent 5baaeafba9
commit 4bf7b36a66
2 changed files with 5 additions and 1 deletions

View File

@@ -4,10 +4,12 @@
// Jason McNeil <https://github.com/jasonrm>
// Christopher Currens <https://github.com/ccurrens>
// Edward Hinkle <https://github.com/edwardhinkle>
// Behind The Math <https://github.com/BehindTheMath>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
import { EventEmitter } from 'events';
import * as processors from './lib/processors';
export function parseString(xml: convertableToString, callback: (err: any, result: any) => void): void;
export function parseString(xml: convertableToString, options: OptionsV2, callback: (err: any, result: any) => void): void;
@@ -76,3 +78,5 @@ export interface OptionsV2 extends Options {
export interface convertableToString {
toString(): string;
}
export { processors };

View File

@@ -33,7 +33,7 @@ xml2js.parseString('<root>Hello xml2js!</root>', {
}, (err: any, result: any) => { });
xml2js.parseString('<root>Hello xml2js!</root>', {
attrNameProcessors: [processors.firstCharLowerCase],
attrNameProcessors: [processors.firstCharLowerCase, xml2js.processors.normalize],
attrValueProcessors: [processors.normalize],
tagNameProcessors: [processors.stripPrefix],
valueProcessors: [processors.parseBooleans, processors.parseNumbers]