git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 8ab7e949190c9ca82f10914e29aae9de082158cb

Files: 8ab7e949190c9ca82f10914e29aae9de082158cb / feed / pull / unique.js

756 bytesRaw
1var pull = require('pull-stream')
2var nest = require('depnest')
3
4exports.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
13exports.gives = nest('feed.pull.unique', true)
14
15exports.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