Adding getProperty to export the ListenerRSS properties + related tests

This commit is contained in:
2021-03-28 13:22:55 +02:00
parent 271f445aef
commit c02df46440
2 changed files with 27 additions and 2 deletions

View File

@ -1,5 +1,8 @@
import Parser from "rss-parser";
import { ListenerRSSInfos as ListenerInfo } from "./Models/ListenerRSSInfos";
import {
ListenerRSSInfos as ListenerInfo,
ListenerRSSInfos,
} from "./Models/ListenerRSSInfos";
import EventEmitter from "events";
const DEFAULT_TIMELOOP: number = 5 * 60; // default timeloop is 5 min
@ -10,7 +13,6 @@ const DEFAULT_TIMELOOP: number = 5 * 60; // default timeloop is 5 min
* Emit 'newEntries' when the fetch has new entris
*/
export class ListenerRss extends EventEmitter {
name: string = "";
address: string = "";
timeloop: number = DEFAULT_TIMELOOP; // time in seconds
customfields?: { [key: string]: string[] | string };
@ -103,4 +105,17 @@ export class ListenerRss extends EventEmitter {
stop(): void {
this.loopRunning = false;
}
/**
* @brief parse the datas inti a ListenerRSSInfos object
* @return return a ListenerRSSInfos object
*/
getProperty(): ListenerRSSInfos {
return {
address: this.address,
customfields: this.customfields,
lastEntriesLinks: this.lastEntriesLinks,
timeloop: this.timeloop,
};
}
}