Comparing version 0.4.1 to 0.5.0
@@ -14,3 +14,3 @@ var util = require('util') | ||
AbstractIterator.call(this, db) | ||
this._reverse = !!options.reverse | ||
this._reverse = options.reverse | ||
this._limit = options.limit | ||
@@ -20,16 +20,30 @@ this._count = 0 | ||
this._start = options.start | ||
this._gt = options.gt | ||
this._gte = options.gte | ||
this._lt = options.lt | ||
this._lte = options.lte | ||
if (this._start && bops.is(this._start) && this._start.length === 0) | ||
this._start = null | ||
if (this._end && bops.is(this._end) && this._end.length === 0) | ||
this._end = null | ||
var i | ||
if (this._start) { | ||
for (var i = 0; i < this.db._keys.length; i++) { | ||
if (this.db._keys[i] >= options.start) { | ||
this._pos = this._reverse && this.db._keys[i] != options.start ? i - 1 : i | ||
for (i = 0; i < this.db._keys.length; i++) { | ||
if (this.db._keys[i] >= this._start) { | ||
this._pos = i | ||
if (this.db._keys[i] != this._start) { | ||
if (this._reverse) { | ||
// going backwards and key doesn't match, jump back one | ||
--this._pos | ||
} | ||
} else { | ||
if (options.exclusiveStart) { | ||
// key matches but it's a gt or lt | ||
this._pos += (this._reverse ? -1 : 1) | ||
} | ||
} | ||
break | ||
} | ||
} | ||
if (this._pos == null && !this._reverse) this._pos = -1 | ||
if (this._pos == null && !this._reverse) // no matching keys, non starter | ||
this._pos = -1 | ||
} | ||
@@ -58,2 +72,8 @@ | ||
if ( (this._lt && key >= this._lt) | ||
|| (this._lte && key > this._lte) | ||
|| (this._gt && key <= this._gt) | ||
|| (this._gte && key < this._gte)) | ||
return setImmediate(callback) | ||
value = self.db._store[toKey(key)] | ||
@@ -60,0 +80,0 @@ self._pos += self._reverse ? -1 : 1 |
{ | ||
"name" : "memdown" | ||
, "description" : "An drop-in replacement for LevelDOWN that works in memory only" | ||
, "version" : "0.4.1" | ||
, "version" : "0.5.0" | ||
, "homepage" : "https://github.com/rvagg/node-memdown" | ||
@@ -19,3 +19,3 @@ , "authors" : [ | ||
, "dependencies" : { | ||
"abstract-leveldown" : "~0.10.2" | ||
"abstract-leveldown" : "~0.11.0" | ||
, "bops" : "~0.1.0" | ||
@@ -22,0 +22,0 @@ } |
@@ -20,4 +20,3 @@ # MemDOWN | ||
, levelup = require('levelup') | ||
, factory = function (location) { return new MemDOWN(location) } | ||
, db = levelup('/does/not/matter', { db: factory }) | ||
, db = levelup('/does/not/matter', { db: MemDOWN }) | ||
@@ -48,2 +47,2 @@ db.put('name', 'Yuri Irsenovich Kim') | ||
MemDOWN is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. | ||
MemDOWN is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. |
@@ -29,2 +29,4 @@ var test = require('tape') | ||
require('abstract-leveldown/abstract/ranges-test').all(MemDOWN, test, testCommon) | ||
test('unsorted entry, sorted iterator', function (t) { | ||
@@ -31,0 +33,0 @@ var db = new MemDOWN('foo') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24957
223
+ Addedabstract-leveldown@0.11.4(transitive)
+ Addedobject-keys@0.4.0(transitive)
+ Addedxtend@2.1.2(transitive)
- Removedabstract-leveldown@0.10.2(transitive)
Updatedabstract-leveldown@~0.11.0