Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
minor changes based on pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Jun 1, 2015
1 parent 8ded32b commit a134de1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Tested & supported platforms
* <a href="#leveldown_getProperty"><code><b>leveldown#getProperty()</b></code></a>
* <a href="#leveldown_iterator"><code><b>leveldown#iterator()</b></code></a>
* <a href="#iterator_next"><code><b>iterator#next()</b></code></a>
* <a href="#iterator_next"><code><b>iterator#next()</b></code></a>
* <a href="#iterator_seek"><code><b>iterator#seek()</b></code></a>
* <a href="#iterator_end"><code><b>iterator#end()</b></code></a>
* <a href="#leveldown_destroy"><code><b>leveldown.destroy()</b></code></a>
* <a href="#leveldown_repair"><code><b>leveldown.repair()</b></code></a>
Expand Down Expand Up @@ -235,8 +235,7 @@ Otherwise, the `callback` function will be called with the following 3 arguments
### iterator#seek(key)
<code>seek()</code> is an instance method on an existing iterator object, used to seek the underlying LevelDB iterator to a given key.

by calling <code>seek(key)</code> subsequent calls to <code>next(cb)</code> will return key/values larger or smaller than <code>key</code>
based on your <code>reverse</code> setting in the iterator constructor.
By calling <code>seek(key)</code>, subsequent calls to <code>next(cb)</code> will return key/values larger or smaller than key, based on your <code>reverse</code> setting in the iterator constructor.

--------------------------------------------------------
<a name="iterator_end"></a>
Expand Down
3 changes: 2 additions & 1 deletion iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function Iterator (db, options) {
util.inherits(Iterator, AbstractIterator)

Iterator.prototype.seek = function (key) {
if (typeof key !== 'string') throw new Error('seek requires a string key')
if (typeof key !== 'string')
throw new Error('seek requires a string key')
this.cache = null
this.binding.seek(key)
}
Expand Down
6 changes: 2 additions & 4 deletions src/iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ NAN_METHOD(Iterator::Seek) {
int cmp = dbIterator->key().compare(*key);
if (cmp > 0 && iterator->reverse) {
dbIterator->Prev();
}
if (cmp < 0 && !iterator->reverse) {
} else if (cmp < 0 && !iterator->reverse) {
dbIterator->Next();
}
} else {
Expand All @@ -233,8 +232,7 @@ NAN_METHOD(Iterator::Seek) {
if (cmp > 0 && iterator->reverse) {
dbIterator->SeekToFirst();
dbIterator->Prev();
}
if (cmp < 0 && !iterator->reverse) {
} else if (cmp < 0 && !iterator->reverse) {
dbIterator->SeekToLast();
dbIterator->Next();
}
Expand Down

0 comments on commit a134de1

Please sign in to comment.