Files: a25ce72e2aaed3ec44c050011d9394502c4cc797 / feed / pull / unique.js
756 bytesRaw
1 | var pull = require('pull-stream') |
2 | var nest = require('depnest') |
3 | |
4 | exports.needs = nest({ |
5 | 'backlinks.obs.for': 'first', |
6 | 'sbot.async.get': 'first', |
7 | 'message.sync.isBlocked': 'first', |
8 | 'message.sync.root': 'first', |
9 | 'message.sync.unbox': 'first', |
10 | 'feed.pull.withReplies': 'first' |
11 | }) |
12 | |
13 | exports.gives = nest('feed.pull.unique', true) |
14 | |
15 | exports.create = function (api) { |
16 | return nest('feed.pull.unique', function (rootFilter) { |
17 | var seen = new Set() |
18 | return pull.filter(idOrMsg => { |
19 | if (idOrMsg) { |
20 | if (idOrMsg.key) idOrMsg = idOrMsg.key |
21 | if (typeof idOrMsg === 'string') { |
22 | var key = idOrMsg |
23 | if (!seen.has(key)) { |
24 | seen.add(key) |
25 | return true |
26 | } |
27 | } |
28 | } |
29 | }) |
30 | }) |
31 | } |
32 |
Built with git-ssb-web