git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit c53665fa2996b120b111466f622b638da4f2f8cf

summary: use deferred instead of pull-pushable

Matt McKegg committed on 3/15/2017, 1:56:44 AM
Parent: c9ae2117d8cc1e874c0094e96620ff2ab36a50bc

Files changed

modules/feed/pull/summary.jschanged
modules/feed/pull/summary.jsView
@@ -1,6 +1,6 @@
11 var pull = require('pull-stream')
2-var pullPushable = require('pull-pushable')
2+var pullDefer = require('pull-defer')
33 var pullNext = require('pull-next')
44 var SortedArray = require('sorted-array-functions')
55 var nest = require('depnest')
66
@@ -25,33 +25,34 @@
2525 var next = {reverse: true, limit: windowSize, live: false}
2626 if (last) {
2727 next.lt = last.timestamp || last.value.sequence
2828 }
29- var pushable = pullPushable()
29+ var deferred = pullDefer.source()
3030 pull(
3131 source(next),
3232 pull.collect((err, values) => {
3333 if (err) throw err
3434 if (!values.length) {
3535 done = true
36- pushable.end()
36+ deferred.resolve(pull.values([]))
3737 if (!returned) cb && cb()
3838 returned = true
3939 } else {
4040 var fromTime = last && last.timestamp || Date.now()
4141 last = values[values.length - 1]
4242 groupMessages(values, fromTime, bumpFilter, (err, result) => {
4343 if (err) throw err
44- result.forEach(v => pushable.push(v))
45- pushable.end()
44+ deferred.resolve(
45+ pull.values(result)
46+ )
4647 if (!returned) cb && cb()
4748 returned = true
4849 })
4950 }
5051 })
5152 )
5253 }
53- return pushable
54+ return deferred
5455 })
5556 }
5657
5758 function groupMessages (messages, fromTime, bumpFilter, cb) {

Built with git-ssb-web