Skip to content

Commit

Permalink
Fix bug where opts = { seqs: true }
Browse files Browse the repository at this point in the history
Previously the code that took care of filtering out deleted items (empty
buffers) just checked whether the item was an empty buffer, but that
doesn't account for the case where `{ seqs: true }` and the value is
actually exposed in `{ value }`.
  • Loading branch information
christianbundy committed May 7, 2019
1 parent e019e26 commit 10d8ff3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 2 additions & 6 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ module.exports = function (blocks, frame, codec, file, cache) {
return pull(
Looper(createStream(opts)),
filter(item => {
let value

if (opts && opts.seqs === false) {
value = item
return isNotDeleted(item)
} else {
value = { item }
return isNotDeleted(item.value)
}

return isNotDeleted(value)
})
)
},
Expand Down
12 changes: 12 additions & 0 deletions test/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ tape('stream', function (t) {

})

tape('stream with options', function (t) {
pull(
db.stream({min: 0, seqs: true}),
pull.collect(function (err, ary) {
if(err) throw err

t.deepEqual(ary.map(item => String(item.value)), ['hello offset db'])
t.end()
})
)
})

tape('live', function (t) {
t.deepEqual(live.map(String), ['hello world', 'hello offset db'])
t.end()
Expand Down

0 comments on commit 10d8ff3

Please sign in to comment.