[Pkg-javascript-commits] [node-leveldown] 170/492: callback is not optional for `close()`

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit a2c8dadf0b8fbfa3b97551b2f93235af3931c646
Author: Rod Vagg <rod at vagg.org>
Date:   Sun Jan 20 16:52:15 2013 +1100

    callback is not optional for `close()`
---
 README.md       | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/database.cc |  4 +--
 2 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index b00a86b..2c1175b 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,95 @@ LevelDOWN
 A Node.js LevelDB binding (currently being extracted from LevelUP)
 -------------------------
 
+<a name="api"></a>
+## API
+
+--------------------------------------------------------
+<a name="createDatabase"></a>
+### leveldown.createDatabase()
+<code>createDatabase()</code> returns a new **LevelDOWN** instance.
+
+--------------------------------------------------------
+<a name="createIterator"></a>
+### leveldown.createIterator(database, options)
+<code>createIterator()</code> returns a new **Iterator** instance for the given database instance.
+
+The `options` object may contain:
+
+* `'start'`: the key you wish to start the read at. By default it will start at the beginning of the store. Note that the *start* doesn't have to be an actual key that exists, LevelDB will simply find the *next* key, greater than the key you provide.
+
+* `'end'`: the key you wish to end the read on. By default it will continue until the end of the store. Again, the *end* doesn't have to be an actual key as an (inclusive) `<=`-type operation is performed to detect the end. You can also use the `destroy()` method instead of supplying an `'end'` parameter to achieve the same effect.
+
+* `'reverse'` *(boolean, default: `false`)*: a boolean, set to true if you want the stream to go in reverse order. Beware that due to the way LevelDB works, a reverse seek will be slower than a forward seek.
+
+* `'keys'` *(boolean, default: `true`)*: whether the `'data'` event should contain keys. If set to `true` and `'values'` set to `false` then `'data'` events will simply be keys, rather than objects with a `'key'` property. Used internally by the `keyStream()` method.
+
+* `'values'` *(boolean, default: `true`)*: whether the `'data'` event should contain values. If set to `true` and `'keys'` set to `false` then `'data'` events will simply be values, rather than objects with a `'value'` property. Used internally by the `valueStream()` method.
+
+* `'limit'` *(number, default: `-1`)*: limit the number of results collected by this stream. This number represents a *maximum* number of results and may not be reached if you get to the end of the store or your `'end'` value first. A value of `-1` means there is no limit.
+
+* `'fillCache'` *(boolean, default: `false`)*: wheather LevelDB's LRU-cache should be filled with data read.
+
+
+--------------------------------------------------------
+<a name="leveldown_open"></a>
+### leveldown#open(location, options, callback)
+<code>open()</code> is an instance method on an existing database object. `location` is a String pointing to the LevelDB location to be opened.
+
+The `options` object may contain:
+
+* `'createIfMissing'` *(boolean, default: `true`)*: If `true`, will initialise an empty database at the specified location if one doesn't already exist. If `false` and a database doesn't exist you will receive an error in your `open()` callback and your database won't open.
+
+* `'errorIfExists'` *(boolean, default: `false`)*: If `true`, you will receive an error in your `open()` callback if the database exists at the specified location.
+
+* `'compression'` *(boolean, default: `true`)*: If `true`, all *compressible* data will be run through the Snappy compression algorithm before being stored. Snappy is very fast and shouldn't gain much speed by disabling so leave this on unless you have good reason to turn it off.
+
+* `'cacheSize'` *(number, default: `8 * 1024 * 1024`)*: The size (in bytes) of the in-memory [LRU](http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used) cache with frequently used uncompressed block contents. 
+
+The `callback` function will be called with no arguments when the database has been successfully opened, or with a single, `error` argument if the open operation failed for any reason.
+
+--------------------------------------------------------
+<a name="leveldown_close"></a>
+### leveldown#close()
+<code>close()</code> is an instance method on an existing database object. 
+
+
+--------------------------------------------------------
+<a name="leveldown_put"></a>
+### leveldown#put()
+<code>put()</code> is an instance method on an existing database object. 
+
+
+--------------------------------------------------------
+<a name="leveldown_get"></a>
+### leveldown#get()
+<code>get()</code> is an instance method on an existing database object. 
+
+
+--------------------------------------------------------
+<a name="leveldown_del"></a>
+### leveldown#batch()
+<code>batch()</code> is an instance method on an existing database object. 
+
+
+--------------------------------------------------------
+<a name="leveldown_approximateSize"></a>
+### leveldown#approximateSize()
+<code>approximateSize()</code> is an instance method on an existing database object. 
+
+
+--------------------------------------------------------
+<a name="iterator_next"></a>
+### iterator#next()
+<code>next()</code> is an instance method on an existing iterator object. 
+
+
+--------------------------------------------------------
+<a name="iterator_end"></a>
+### iterator#end()
+<code>end()</code> is an instance method on an existing iterator object. 
+
+
 <a name="contributing"></a>
 Contributing
 ------------
diff --git a/src/database.cc b/src/database.cc
index 25957b0..9dcdb94 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -149,9 +149,7 @@ Handle<Value> Database::Close (const Arguments& args) {
   HandleScope scope;
 
   Database* database = ObjectWrap::Unwrap<Database>(args.This());
-  Persistent<Function> callback;
-  if (args.Length() > 0)
-    callback = Persistent<Function>::New(Local<Function>::Cast(args[0]));
+  Persistent<Function> callback = Persistent<Function>::New(Local<Function>::Cast(args[0]));
 
   CloseWorker* worker = new CloseWorker(database, callback);
   AsyncQueueWorker(worker);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list