From 10d8ff3d600c7404cf3a8cb6d890068227925ab0 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Mon, 6 May 2019 17:15:46 -0700 Subject: [PATCH] Fix bug where `opts = { seqs: true }` 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 }`. --- inject.js | 8 ++------ test/simple.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/inject.js b/inject.js index ad3b271..c9547e6 100644 --- a/inject.js +++ b/inject.js @@ -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) }) ) }, diff --git a/test/simple.js b/test/simple.js index 0d4a98a..8733503 100644 --- a/test/simple.js +++ b/test/simple.js @@ -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()