You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
705 B
26 lines
705 B
|
|
|
|
var pull = require('pull-stream') |
|
var defer = require('pull-defer/source') |
|
// Currently this uses pull streams, |
|
// and not levelup's readstream, but in theory |
|
// I should be able pretty much just drop that in. |
|
|
|
module.exports = function pullReadStream (options, makeData) { |
|
var stream = defer() |
|
|
|
stream.setIterator = function (iterator) { |
|
stream.resolve(function (end, cb) { |
|
if(!end) iterator.next(function (err, key, value) { |
|
if(err) return cb(err) |
|
if(key === undefined || value === undefined) |
|
return cb(true) |
|
cb(null, makeData(key, value)) |
|
}) |
|
else |
|
iterator.end(cb) |
|
}) |
|
} |
|
|
|
return stream |
|
}
|
|
|