ripunzel/fetch/info.js

22 lines
567 B
JavaScript

'use strict';
const methods = require('../methods/methods.js');
function fetchInfo(posts) {
return Promise.all(posts.reduce((acc, post) => {
if(post.host && methods[post.host.method]) {
acc = acc.concat(methods[post.host.method](post).then(content => {
post.content = content;
return post;
}));
} else {
console.log('\x1b[33m%s\x1b[0m', `Ignoring unsupported content '${post.title}' - ${post.url}`);
}
return acc;
}, []));
};
module.exports = fetchInfo;