db: fix level-js iterators.
This commit is contained in:
parent
a143c78369
commit
2d61a43fba
@ -105,11 +105,18 @@ function Iterator(db, options) {
|
||||
options.keyAsBuffer = false;
|
||||
this.db = db;
|
||||
this.iter = db.level.iterator(options);
|
||||
this._end = false;
|
||||
}
|
||||
|
||||
Iterator.prototype.next = function(callback) {
|
||||
var self = this;
|
||||
this.iter.next(function(err, key, value) {
|
||||
// Hack for level-js: it doesn't actually
|
||||
// end iterators -- it keeps streaming keys
|
||||
// and values.
|
||||
if (self._end)
|
||||
return;
|
||||
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -137,6 +144,7 @@ Iterator.prototype.seek = function seek(key) {
|
||||
};
|
||||
|
||||
Iterator.prototype.end = function end(callback) {
|
||||
this._end = true;
|
||||
this.iter.end(callback);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user