From 3314338186415138a3602fd33dc5b22f9ba79a5b Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Thu, 11 Sep 2014 09:43:08 -0700 Subject: [PATCH 1/3] no real change --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e..3091757 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +coverage \ No newline at end of file From b69148e4f2c531dacb28d01766ee55973105d36f Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Thu, 11 Sep 2014 10:11:25 -0700 Subject: [PATCH 2/3] fix the snapshot issues --- .gitignore | 3 +-- memdown.js | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3091757..b512c09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -node_modules -coverage \ No newline at end of file +node_modules \ No newline at end of file diff --git a/memdown.js b/memdown.js index 9c6a127..7c8abfe 100644 --- a/memdown.js +++ b/memdown.js @@ -35,6 +35,10 @@ function MemIterator (db, options) { if (options.limit > 0) this._keys = this._keys.slice(0, options.limit) + this._store = {}; + Object.keys(this.db._store).forEach(function (key) { + this._store[key] = this.db._store[key]; + }, this); } inherits(MemIterator, AbstractIterator) @@ -49,7 +53,7 @@ MemIterator.prototype._next = function (callback) { key = self._keys[self._pos] - value = self.db._store[toKey(key)] + value = self._store[toKey(key)] this._pos++ From 83c066079122026458e7dea861f44f2533f11cfe Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Fri, 12 Sep 2014 09:02:41 -0700 Subject: [PATCH 3/3] pass tests --- .gitignore | 2 +- memdown.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b512c09..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -node_modules \ No newline at end of file +node_modules diff --git a/memdown.js b/memdown.js index 7c8abfe..7066c62 100644 --- a/memdown.js +++ b/memdown.js @@ -24,7 +24,8 @@ function MemIterator (db, options) { this._reverse = options.reverse this._keys = [] this._options = options - + this.keyAsBuffer = options.keyAsBuffer !== false + this.valueAsBuffer = options.valueAsBuffer !== false this._pos = 0 this._keys = this.db._keys.filter(ltgt.filter(options)) @@ -56,6 +57,12 @@ MemIterator.prototype._next = function (callback) { value = self._store[toKey(key)] this._pos++ + + if (self.keyAsBuffer) + key = new Buffer(key) + + if (self.valueAsBuffer) + value = new Buffer(value) setImmediate(function () { callback(null, key, value) }) }