Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit a847d68

Browse files
committed
refactor: code cleanup
1 parent 3f9fa0f commit a847d68

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

.eslintrc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"root": true,
3-
"extends": [
4-
"finn",
5-
"finn/node",
6-
"finn-prettier"
7-
],
3+
"extends": ["finn", "finn/node", "finn-prettier"],
84
"parserOptions": {
9-
"ecmaVersion": 2017
5+
"ecmaVersion": 2017,
6+
"ecmaFeatures": {
7+
"experimentalObjectRestSpread": true
8+
}
109
},
1110
"env": {
1211
"node": true,
1312
"jest": true
1413
}
15-
}
14+
}

lib/reader.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ module.exports = async function reader(feeds = []) {
1212
`Expected every feed to be an array. Instead got "${feeds.join(', ')}"`
1313
);
1414

15-
feeds = feeds.reduce((prev, current) => prev.concat(current), []);
15+
feeds = [].concat(...feeds);
1616

17-
const map = new Map();
17+
const feedMap = new Map();
1818
feeds.forEach(feed => {
19-
// because map preserves order, when we get a duplicate we actually
20-
// need to append to the end of the map. We do that by deleting
21-
// first and then adding to the map
22-
map.delete(feed.id);
23-
map.set(feed.id, feed);
19+
// because feedMap preserves order, when we get a duplicate we actually
20+
// need to append to the end of the feedMap. We do that by deleting
21+
// first and then adding to the feedMap
22+
feedMap.delete(feed.id);
23+
feedMap.set(feed.id, feed);
2424
});
25-
return Array.from(map.values())
26-
.map(feed => feed.content.trim())
27-
.join('\n\n');
25+
const dedupedFeeds = Array.from(feedMap.values());
26+
return dedupedFeeds.map(feed => feed.content.trim()).join('\n\n');
2827
};

0 commit comments

Comments
 (0)