Home
/
rss-reader.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6e5224b
)
extract the parser api to a base class
author
xangelo
<git@xangelo.ca>
Wed, 6 Apr 2022 16:47:56 +0000
(12:47 -0400)
committer
xangelo
<git@xangelo.ca>
Wed, 6 Apr 2022 16:47:56 +0000
(12:47 -0400)
src/parsers/base.ts
patch
|
blob
|
history
src/parsers/rss.ts
patch
|
blob
|
history
diff --git
a/src/parsers/base.ts
b/src/parsers/base.ts
index 64aaa8b60ff894cace3f5afc1b11a79fedbb503c..acf9a250037364fec06eff3cc8976a9f687113f2 100644
(file)
--- a/
src/parsers/base.ts
+++ b/
src/parsers/base.ts
@@
-11,3
+11,7
@@
export type Feed = {
link: string;
items: FeedItem[];
};
+
+export abstract class BaseParser {
+ abstract parse(url: string): Promise<Feed>;
+}
diff --git
a/src/parsers/rss.ts
b/src/parsers/rss.ts
index d23dcc2327b0c348dd0c605d2c58dd55e04a4754..e2db58d7ef130576cd42efd7073fb2f937c9db9a 100644
(file)
--- a/
src/parsers/rss.ts
+++ b/
src/parsers/rss.ts
@@
-1,5
+1,5
@@
import Parser from 'rss-parser';
-import {Feed} from './base';
+import {Feed
, BaseParser
} from './base';
function timestamp(str: string): number {
const date = +(new Date(str));
@@
-13,9
+13,10
@@
function reasonable(dateStr: string): string {
return `${date.getFullYear()}-${month}-${day}`;
}
-export class RSSParser {
+export class RSSParser
extends BaseParser
{
parser: Parser;
constructor() {
+ super();
this.parser = new Parser;
}