Commit 32f894d5b634ccd79fb713e98e1ab5f5cf7d9819
Fix u.next looping on empty streams
Charles Lehner committed on 6/30/2016, 2:32:13 PMParent: 7943e743e227f271fee302ea63fc033e49f380bc
Files changed
util.js | changed |
util.js | ||
---|---|---|
@@ -39,18 +39,21 @@ | ||
39 | 39 | return Next(function () { |
40 | 40 | if(last) { |
41 | 41 | if(count === 0) return |
42 | 42 | var value = opts[range] = get(last, property) |
43 | - if(value === stop) return null | |
43 | + if(value == null) return | |
44 | + last = null | |
44 | 45 | } |
45 | 46 | return pull( |
46 | 47 | createStream(opts), |
47 | 48 | pull.through(function (msg) { |
48 | 49 | count ++ |
49 | 50 | if(!msg.sync) last = msg |
50 | 51 | }, function (err) { |
51 | 52 | //retry on errors... |
52 | - if(err) count = -1 | |
53 | + if(err) return count = -1 | |
54 | + //end stream if there were no results | |
55 | + if(last == null) last = {} | |
53 | 56 | }) |
54 | 57 | ) |
55 | 58 | }) |
56 | 59 | } |
Built with git-ssb-web