mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
xml2js - Prevent error when using Parser's event emitter (#14884)
* Make Parser extend event emitter Fixing error: error TS2339: Property 'on' does not exist on type 'Parser'. * Update authorship * Add test for event emitter
This commit is contained in:
parent
16a70ebb0d
commit
ddef2004bc
6
xml2js/index.d.ts
vendored
6
xml2js/index.d.ts
vendored
@ -1,12 +1,14 @@
|
||||
// Type definitions for node-xml2js
|
||||
// Project: https://github.com/Leonidas-from-XIV/node-xml2js
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Jason McNeil <https://github.com/jasonrm>, Christopher Currens <https://github.com/ccurrens>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Jason McNeil <https://github.com/jasonrm>, Christopher Currens <https://github.com/ccurrens>, Edward Hinkle <https://github.com/edwardhinkle>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="./processors.d.ts" />
|
||||
|
||||
export = xml2js;
|
||||
|
||||
import * as events from 'events'
|
||||
|
||||
declare namespace xml2js {
|
||||
function parseString(xml: convertableToString, callback: (err: any, result: any) => void): void;
|
||||
function parseString(xml: convertableToString, options: OptionsV2, callback: (err: any, result: any) => void): void;
|
||||
@ -21,7 +23,7 @@ declare namespace xml2js {
|
||||
buildObject(rootObj: any): string;
|
||||
}
|
||||
|
||||
class Parser {
|
||||
class Parser extends events.EventEmitter {
|
||||
constructor(options?: OptionsV2);
|
||||
parseString(str: convertableToString, cb?: Function): void;
|
||||
reset(): void;
|
||||
|
||||
@ -69,6 +69,11 @@ var outString = builder.buildObject({
|
||||
|
||||
var parser = new xml2js.Parser();
|
||||
|
||||
parser.on('end', (result: any) => {
|
||||
console.log("Parser Finished");
|
||||
return;
|
||||
});
|
||||
|
||||
var v1Defaults = xml2js.defaults['0.1'];
|
||||
v1Defaults.async = true;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user