Skip to content

Commit

Permalink
fixes issue Seneca-CDOT#16, created a function to parse feed
Browse files Browse the repository at this point in the history
  • Loading branch information
c3ho committed Nov 9, 2019
1 parent aca7929 commit ef1b23a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"bent": "^7.0.2",
"bull": "^3.11.0",
"feedparser": "^2.2.9"
"feedparser-promised": "^2.0.1"
},
"devDependencies": {
"eslint": "^6.6.0",
Expand Down
20 changes: 5 additions & 15 deletions src/feed-parser.js
@@ -1,17 +1,7 @@
const FeedParser = require('feedparser');
const bent = require('bent');
const feedparser = require('feedparser-promised');

// feed: url feed
// Accepts a url feed and parses it, on success will return the stream
module.exports = async function(feed){
const feedparser = new FeedParser();
const getStream = bent(feed);

let stream = await getStream('/json.api');
return new Promise((resolve,reject)=>{
stream.pipe(feedparser)
.on('error', reject)
.on('readable', resolve);
})
// feed: url for the feed
// Accepts a url feed and parses it, on success will return a stream
module.exports = async function (feed) {
return feedparser.parse(feed);
};

0 comments on commit ef1b23a

Please sign in to comment.