Commit c53665fa2996b120b111466f622b638da4f2f8cf
summary: use deferred instead of pull-pushable
Matt McKegg committed on 3/15/2017, 1:56:44 AMParent: c9ae2117d8cc1e874c0094e96620ff2ab36a50bc
Files changed
modules/feed/pull/summary.js | changed |
modules/feed/pull/summary.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 … | var pull = require('pull-stream') |
2 | -var pullPushable = require('pull-pushable') | |
2 … | +var pullDefer = require('pull-defer') | |
3 | 3 … | var pullNext = require('pull-next') |
4 | 4 … | var SortedArray = require('sorted-array-functions') |
5 | 5 … | var nest = require('depnest') |
6 | 6 … | |
@@ -25,33 +25,34 @@ | ||
25 | 25 … | var next = {reverse: true, limit: windowSize, live: false} |
26 | 26 … | if (last) { |
27 | 27 … | next.lt = last.timestamp || last.value.sequence |
28 | 28 … | } |
29 | - var pushable = pullPushable() | |
29 … | + var deferred = pullDefer.source() | |
30 | 30 … | pull( |
31 | 31 … | source(next), |
32 | 32 … | pull.collect((err, values) => { |
33 | 33 … | if (err) throw err |
34 | 34 … | if (!values.length) { |
35 | 35 … | done = true |
36 | - pushable.end() | |
36 … | + deferred.resolve(pull.values([])) | |
37 | 37 … | if (!returned) cb && cb() |
38 | 38 … | returned = true |
39 | 39 … | } else { |
40 | 40 … | var fromTime = last && last.timestamp || Date.now() |
41 | 41 … | last = values[values.length - 1] |
42 | 42 … | groupMessages(values, fromTime, bumpFilter, (err, result) => { |
43 | 43 … | if (err) throw err |
44 | - result.forEach(v => pushable.push(v)) | |
45 | - pushable.end() | |
44 … | + deferred.resolve( | |
45 … | + pull.values(result) | |
46 … | + ) | |
46 | 47 … | if (!returned) cb && cb() |
47 | 48 … | returned = true |
48 | 49 … | }) |
49 | 50 … | } |
50 | 51 … | }) |
51 | 52 … | ) |
52 | 53 … | } |
53 | - return pushable | |
54 … | + return deferred | |
54 | 55 … | }) |
55 | 56 … | } |
56 | 57 … | |
57 | 58 … | function groupMessages (messages, fromTime, bumpFilter, cb) { |
Built with git-ssb-web