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

Commit

Permalink
minor style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Aug 18, 2014
1 parent 1c7bc43 commit 74caa18
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/levelup.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ LevelUP.prototype.isClosed = function () {
}

function maybeError(db, options, callback) {

if (!db._isOpening() && !db.isOpen()) {
dispatchError(
db
Expand Down Expand Up @@ -200,9 +199,10 @@ LevelUP.prototype.get = function (key_, options, callback) {

callback = getCallback(options, callback)

if (maybeError(this, options, callback)) return
if (maybeError(this, options, callback))
return

if(key_ === null || key_ === undefined || 'function' !== typeof callback)
if (key_ === null || key_ === undefined || 'function' !== typeof callback)
return readError(this
, 'get() requires key and callback arguments', callback)

Expand Down Expand Up @@ -239,11 +239,12 @@ LevelUP.prototype.put = function (key_, value_, options, callback) {

callback = getCallback(options, callback)

if(key_ === null || key_ === undefined
if (key_ === null || key_ === undefined
|| value_ === null || value_ === undefined)
return writeError(this, 'put() requires key and value arguments', callback)

if(maybeError(this, options, callback)) return
if (maybeError(this, options, callback))
return

options = getOptions(this, options)
key = this._codec.encodeKey(key_, options)
Expand All @@ -266,10 +267,11 @@ LevelUP.prototype.del = function (key_, options, callback) {

callback = getCallback(options, callback)

if(key_ === null || key_ === undefined)
if (key_ === null || key_ === undefined)
return writeError(this, 'del() requires a key argument', callback)

if(maybeError(this, options, callback)) return
if (maybeError(this, options, callback))
return

options = getOptions(this, options)
key = this._codec.encodeKey(key_, options)
Expand All @@ -296,10 +298,11 @@ LevelUP.prototype.batch = function (arr_, options, callback) {

callback = getCallback(options, callback)

if(!Array.isArray(arr_))
if (!Array.isArray(arr_))
return writeError(this, 'batch() requires an array argument', callback)

if(maybeError(this, options, callback)) return
if (maybeError(this, options, callback))
return

options = getOptions(this, options)
keyEnc = options.keyEncoding
Expand Down Expand Up @@ -355,7 +358,7 @@ LevelUP.prototype.approximateSize = function (start_, end_, options, callback) {

options = getOptions(options, callback)

if(start_ === null || start_ === undefined
if (start_ === null || start_ === undefined
|| end_ === null || end_ === undefined || 'function' !== typeof callback)
return readError(this, 'approximateSize() requires start, end and callback arguments', callback)

Expand Down Expand Up @@ -416,12 +419,13 @@ LevelUP.prototype.createReadStream = function (options) {

var stream = new ReadStream(options, makeData)

if(this.isOpen())
if (this.isOpen()) {
stream.setIterator(self.db.iterator(options))
else
} else {
this.once('ready', function () {
stream.setIterator(self.db.iterator(options))
})
}

return stream
}
Expand Down

0 comments on commit 74caa18

Please sign in to comment.