New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

levelup

Package Overview
Dependencies
Maintainers
3
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

levelup - npm Package Compare versions

Comparing version 0.19.0 to 1.0.0-0

4

CHANGELOG.md

@@ -57,3 +57,3 @@ ### 0.18.6 @ Aug 26 2014

* Use LevelDOWN@0.5.0, see https://github.com/rvagg/node-leveldown/blob/master/CHANGELOG.md for details
* Use LevelDOWN@0.5.0, see https://github.com/level/leveldown/blob/master/CHANGELOG.md for details
* Race-condition(ish) fixed in ReadStream--createReadStream() does not start immediately and therefore allowed put()s to happen before the stream starts (@dominictarr)

@@ -102,3 +102,3 @@ * ReadStream doesn't emit "ready" event (@dominictarr)

* complete transition to LevelDOWN for the LevelDB binding. No native code left in LevelUP @rvagg
- LevelDOWN now keeps its own ChangeLog at: https://github.com/rvagg/node-leveldown/blob/master/CHANGELOG.md
- LevelDOWN now keeps its own ChangeLog at: https://github.com/level/leveldown/blob/master/CHANGELOG.md
- LevelDB@1.9.0 and Snappy@1.1.0 are included in LevelDOWN@0.1.2

@@ -105,0 +105,0 @@ * simplify callback signature (remove extra, undocumented properties from some callbacks) @rvagg / @dominictarr

@@ -1,9 +0,9 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
* <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var util = require('./util')
, WriteError = require('./errors').WriteError
, WriteError = require('level-errors').WriteError

@@ -21,3 +21,3 @@ , getOptions = util.getOptions

Batch.prototype.put = function (key_, value_, options) {
options = getOptions(this._levelup, options)
options = getOptions(options)

@@ -38,3 +38,3 @@ var key = this._codec.encodeKey(key_, options)

Batch.prototype.del = function (key_, options) {
options = getOptions(this._levelup, options)
options = getOptions(options)

@@ -41,0 +41,0 @@ var key = this._codec.encodeKey(key_, options)

@@ -1,31 +0,31 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
* <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var EventEmitter = require('events').EventEmitter
, inherits = require('util').inherits
, extend = require('xtend')
, prr = require('prr')
, DeferredLevelDOWN = require('deferred-leveldown')
var EventEmitter = require('events').EventEmitter
, inherits = require('util').inherits
, extend = require('xtend')
, prr = require('prr')
, DeferredLevelDOWN = require('deferred-leveldown')
, WriteError = require('./errors').WriteError
, ReadError = require('./errors').ReadError
, NotFoundError = require('./errors').NotFoundError
, OpenError = require('./errors').OpenError
, EncodingError = require('./errors').EncodingError
, InitializationError = require('./errors').InitializationError
, errors = require('level-errors')
, WriteError = errors.WriteError
, ReadError = errors.ReadError
, NotFoundError = errors.NotFoundError
, OpenError = errors.OpenError
, EncodingError = errors.EncodingError
, InitializationError = errors.InitializationError
, ReadStream = require('./read-stream')
, WriteStream = require('./write-stream')
, util = require('./util')
, Batch = require('./batch')
, codec = require('./codec')
, ReadStream = require('./read-stream')
, util = require('./util')
, Batch = require('./batch')
, Codec = require('level-codec')
, getOptions = util.getOptions
, defaultOptions = util.defaultOptions
, getLevelDOWN = util.getLevelDOWN
, dispatchError = util.dispatchError
, isDefined = util.isDefined
, getOptions = util.getOptions
, defaultOptions = util.defaultOptions
, getLevelDOWN = util.getLevelDOWN
, dispatchError = util.dispatchError
, isDefined = util.isDefined

@@ -79,5 +79,5 @@ function getCallback (options, callback) {

options = getOptions(this, options)
options = getOptions(options)
this.options = extend(defaultOptions, options)
this._codec = options.codec || codec
this._codec = new Codec(this.options)
this._status = 'new'

@@ -144,3 +144,3 @@ // set this.location as enumerable but not configurable or writable

this.emit('closing')
this.db = null
this.db = new DeferredLevelDOWN(this.location)
} else if (this._status == 'closed' && callback) {

@@ -211,10 +211,10 @@ return process.nextTick(callback)

options = util.getOptions(this, options)
options = util.getOptions(options)
key = this._codec.encodeKey(key_, options)
options.asBuffer = this._codec.isValueAsBuffer(options)
options.asBuffer = this._codec.valueAsBuffer(options)
this.db.get(key, options, function (err, value) {
if (err) {
if ((/notfound/i).test(err)) {
if ((/notfound/i).test(err) || err.notFound) {
err = new NotFoundError(

@@ -245,5 +245,4 @@ 'Key not found in database [' + key_ + ']', err)

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

@@ -253,3 +252,3 @@ if (maybeError(this, options, callback))

options = getOptions(this, options)
options = getOptions(options)
key = this._codec.encodeKey(key_, options)

@@ -281,3 +280,3 @@ value = this._codec.encodeValue(value_, options)

options = getOptions(this, options)
options = getOptions(options)
key = this._codec.encodeKey(key_, options)

@@ -303,3 +302,3 @@

if (!arguments.length)
return new Batch(this, codec)
return new Batch(this, this._codec)

@@ -314,35 +313,5 @@ callback = getCallback(options, callback)

options = getOptions(this, options)
keyEnc = options.keyEncoding
valueEnc = options.valueEncoding
options = getOptions(options)
arr = self._codec.encodeBatch(arr_, options)
arr = arr_.map(function (e) {
if (e.type === undefined || e.key === undefined)
return {}
// inherit encoding
var kEnc = e.keyEncoding || keyEnc
, vEnc = e.valueEncoding || e.encoding || valueEnc
, o
// If we're not dealing with plain utf8 strings or plain
// Buffers then we have to do some work on the array to
// encode the keys and/or values. This includes JSON types.
if (kEnc != 'utf8' && kEnc != 'binary'
|| vEnc != 'utf8' && vEnc != 'binary') {
o = {
type: e.type
, key: self._codec.encodeKey(e.key, options, e)
}
if (e.value !== undefined)
o.value = self._codec.encodeValue(e.value, options, e)
return o
} else {
return e
}
})
this.db.batch(arr, options, function (err) {

@@ -367,3 +336,3 @@ if (err) {

options = getOptions(options, callback)
options = getOptions(options)

@@ -374,4 +343,4 @@ if (start_ === null || start_ === undefined

start = this._codec.encodeKey(start_, this.options)
end = this._codec.encodeKey(end_, this.options)
start = this._codec.encodeKey(start_, options)
end = this._codec.encodeKey(end_, options)

@@ -392,22 +361,22 @@ this.db.approximateSize(start, end, function (err, size) {

options.keyEncoding = options.keyEncoding || options.encoding
options.valueEncoding = options.valueEncoding || options.encoding
options.keyEncoding = options.keyEncoding
options.valueEncoding = options.valueEncoding
if (isDefined(options.start))
options.start = this._codec.encodeKey(options.start, options)
options.start = this._codec.encodeKey(options.start, [options])
if (isDefined(options.end))
options.end = this._codec.encodeKey(options.end, options)
options.end = this._codec.encodeKey(options.end, [options])
if (isDefined(options.gte))
options.gte = this._codec.encodeKey(options.gte, options)
options.gte = this._codec.encodeKey(options.gte, [options])
if (isDefined(options.gt))
options.gt = this._codec.encodeKey(options.gt, options)
options.gt = this._codec.encodeKey(options.gt, [options])
if (isDefined(options.lte))
options.lte = this._codec.encodeKey(options.lte, options)
options.lte = this._codec.encodeKey(options.lte, [options])
if (isDefined(options.lt))
options.lt = this._codec.encodeKey(options.lt, options)
options.lt = this._codec.encodeKey(options.lt, [options])
if ('number' !== typeof options.limit)
options.limit = -1
options.keyAsBuffer = this._codec.isKeyAsBuffer(options)
options.valueAsBuffer = this._codec.isValueAsBuffer(options)
options.keyAsBuffer = this._codec.keyAsBuffer([options])
options.valueAsBuffer = this._codec.valueAsBuffer([options])

@@ -417,4 +386,4 @@ var makeData = options.keys && options.values

return {
key: self._codec.decodeKey(key, options)
, value: self._codec.decodeValue(value, options)
key: self._codec.decodeKey(key, [options])
, value: self._codec.decodeValue(value, [options])
}

@@ -424,21 +393,11 @@ }

? function (key) {
return self._codec.decodeKey(key, options)
return self._codec.decodeKey(key, [options])
}
: options.values
? function (_, value) {
return self._codec.decodeValue(value, options)
return self._codec.decodeValue(value, [options])
}
: function () {}
var stream = new ReadStream(options, makeData)
if (this.isOpen()) {
stream.setIterator(self.db.iterator(options))
} else {
this.once('ready', function () {
stream.setIterator(self.db.iterator(options))
})
}
return stream
return new ReadStream(this.db.iterator(options), options, makeData)
}

@@ -456,8 +415,2 @@

LevelUP.prototype.writeStream =
LevelUP.prototype.createWriteStream = function (options) {
//XXX is extend needed here?
return new WriteStream(extend(options), this)
}
LevelUP.prototype.toString = function () {

@@ -474,3 +427,3 @@ return 'LevelUP'

module.exports = LevelUP
module.exports.copy = util.copy
module.exports.errors = require('level-errors')
// DEPRECATED: prefer accessing LevelDOWN for this: require('leveldown').destroy()

@@ -477,0 +430,0 @@ module.exports.destroy = utilStatic('destroy')

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -11,3 +11,3 @@

, extend = require('xtend')
, EncodingError = require('./errors').EncodingError
, EncodingError = require('level-errors').EncodingError
, util = require('./util')

@@ -17,5 +17,5 @@

function ReadStream (options, makeData) {
function ReadStream (iterator, options, makeData) {
if (!(this instanceof ReadStream))
return new ReadStream(options, makeData)
return new ReadStream(iterator, options, makeData)

@@ -26,3 +26,3 @@ Readable.call(this, { objectMode: true, highWaterMark: options.highWaterMark })

this._waiting = false
this._iterator = iterator
this._options = options

@@ -34,13 +34,2 @@ this._makeData = makeData

ReadStream.prototype.setIterator = function (it) {
var self = this
this._iterator = it
if(this._destroyed) return it.end(function () {})
if(this._waiting) {
this._waiting = false
return this._read()
}
return this
}
ReadStream.prototype._read = function read () {

@@ -50,4 +39,2 @@ var self = this

return
if(!self._iterator)
return this._waiting = true

@@ -82,10 +69,6 @@ self._iterator.next(function(err, key, value) {

if (self._iterator) {
self._iterator.end(function () {
self._iterator = null
self.emit('close')
})
} else {
self._iterator.end(function () {
self._iterator = null
self.emit('close')
}
})
}

@@ -92,0 +75,0 @@

@@ -1,10 +0,9 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
* <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var extend = require('xtend')
, LevelUPError = require('./errors').LevelUPError
, encodings = require('./encodings')
, LevelUPError = require('level-errors').LevelUPError
, defaultOptions = {

@@ -19,27 +18,11 @@ createIfMissing : true

, leveldown
, encodingOpts = (function () {
var eo = {}
for(var e in encodings)
eo[e] = {valueEncoding: encodings[e]}
return eo
}())
function copy (srcdb, dstdb, callback) {
srcdb.readStream()
.pipe(dstdb.writeStream())
.on('close', callback ? callback : function () {})
.on('error', callback ? callback : function (err) { throw err })
function getOptions (options) {
if (typeof options == 'string')
options = { valueEncoding: options }
if (typeof options != 'object')
options = {}
return options
}
function getOptions (levelup, options) {
var s = typeof options == 'string' // just an encoding
if (!s && options && options.encoding && !options.valueEncoding)
options.valueEncoding = options.encoding
return extend(
(levelup && levelup.options) || {}
, s ? encodingOpts[options] || encodingOpts[defaultOptions.valueEncoding]
: options
)
}
function getLevelDOWN () {

@@ -88,3 +71,2 @@ if (leveldown)

defaultOptions : defaultOptions
, copy : copy
, getOptions : getOptions

@@ -91,0 +73,0 @@ , getLevelDOWN : getLevelDOWN

The MIT License (MIT)
=====================
Copyright (c) 2014 LevelUP contributors
Copyright (c) 2012-2015 LevelUP contributors
---------------------------------------
*LevelUP contributors listed at <https://github.com/rvagg/node-levelup#contributors>*
*LevelUP contributors listed at <https://github.com/level/levelup#contributors>*

@@ -9,0 +9,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

{
"name": "levelup",
"description": "Fast & simple storage - a Node.js-style LevelDB wrapper",
"version": "0.19.0",
"version": "1.0.0-0",
"contributors": [

@@ -11,3 +11,3 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)",

"Max Ogden <max@maxogden.com> (https://github.com/maxogden)",
"Lars-Magnus Skog <lars.magnus.skog@gmail.com> (https://github.com/ralphtheninja)",
"Lars-Magnus Skog <ralphtheninja@riseup.net> (https://github.com/ralphtheninja)",
"David Björklund <david.bjorklund@gmail.com> (https://github.com/kesla)",

@@ -19,9 +19,10 @@ "Julian Gruber <julian@juliangruber.com> (https://github.com/juliangruber)",

"Pedro Teixeira <pedro.teixeira@gmail.com> (https://github.com/pgte)",
"James Halliday <mail@substack.net> (https://github.com/substack)"
"James Halliday <mail@substack.net> (https://github.com/substack)",
"Jarrett Cruger <jcrugzz@gmail.com> (https://github.com/jcrugzz)"
],
"repository": {
"type": "git",
"url": "https://github.com/rvagg/node-levelup.git"
"url": "https://github.com/level/levelup.git"
},
"homepage": "https://github.com/rvagg/node-levelup",
"homepage": "https://github.com/level/levelup",
"keywords": [

@@ -38,5 +39,5 @@ "leveldb",

"dependencies": {
"bl": "~0.8.1",
"deferred-leveldown": "~0.2.0",
"errno": "~0.1.1",
"deferred-leveldown": "^0.3.0",
"level-codec": "^5.0.0",
"level-errors": "~1.0.3",
"prr": "~0.0.0",

@@ -48,18 +49,13 @@ "readable-stream": "~1.0.26",

"devDependencies": {
"leveldown": "~0.10.0",
"bustermove": "*",
"tap": "*",
"referee": "*",
"rimraf": "*",
"async": "*",
"fstream": "*",
"tar": "*",
"mkfiletree": "*",
"readfiletree": "*",
"slow-stream": ">=0.0.4",
"delayed": "*",
"boganipsum": "*",
"du": "*",
"memdown": "*",
"msgpack-js": "*"
"async": "~0.9.0",
"bustermove": "~0.4.1",
"delayed": "~1.0.1",
"du": "~0.1.0",
"leveldown": "~1.0.0",
"memdown": "~1.0.0",
"msgpack-js": "~0.3.0",
"referee": "~1.1.1",
"rimraf": "~2.2.8",
"tap": "~0.4.13",
"slow-stream": "0.0.4"
},

@@ -72,7 +68,5 @@ "browser": {

"scripts": {
"test": "tap test/*-test.js --stderr",
"functionaltests": "node ./test/functional/fstream-test.js && node ./test/functional/binary-data-test.js && node ./test/functional/compat-test.js",
"alltests": "npm test && npm run-script functionaltests"
"test": "tap test/*-test.js --stderr"
},
"license": "MIT"
}
LevelUP
=======
![LevelDB Logo](https://0.gravatar.com/avatar/a498b122aecb7678490a38bb593cc12d)
<img alt="LevelDB Logo" height="100" src="http://leveldb.org/img/logo.svg">
**Fast & simple storage - a Node.js-style LevelDB wrapper**
[![Build Status](https://secure.travis-ci.org/rvagg/node-levelup.png)](http://travis-ci.org/rvagg/node-levelup)
[![Build Status](https://secure.travis-ci.org/Level/levelup.png)](http://travis-ci.org/Level/levelup)

@@ -31,5 +31,5 @@ [![NPM](https://nodei.co/npm/levelup.png?stars&downloads&downloadRank)](https://nodei.co/npm/levelup/) [![NPM](https://nodei.co/npm-dl/levelup.png?months=6&height=3)](https://nodei.co/npm/levelup/)

**[LevelDB](http://code.google.com/p/leveldb/)** is a simple key/value data store built by Google, inspired by BigTable. It's used in Google Chrome and many other products. LevelDB supports arbitrary byte arrays as both keys and values, singular *get*, *put* and *delete* operations, *batched put and delete*, bi-directional iterators and simple compression using the very fast [Snappy](http://code.google.com/p/snappy/) algorithm.
**[LevelDB](https://github.com/google/leveldb)** is a simple key/value data store built by Google, inspired by BigTable. It's used in Google Chrome and many other products. LevelDB supports arbitrary byte arrays as both keys and values, singular *get*, *put* and *delete* operations, *batched put and delete*, bi-directional iterators and simple compression using the very fast [Snappy](http://code.google.com/p/snappy/) algorithm.
**LevelUP** aims to expose the features of LevelDB in a **Node.js-friendly way**. All standard `Buffer` encoding types are supported, as is a special JSON encoding. LevelDB's iterators are exposed as a Node.js-style **readable stream** a matching **writeable stream** converts writes to *batch* operations.
**LevelUP** aims to expose the features of LevelDB in a **Node.js-friendly way**. All standard `Buffer` encoding types are supported, as is a special JSON encoding. LevelDB's iterators are exposed as a Node.js-style **readable stream**.

@@ -44,7 +44,7 @@ LevelDB stores entries **sorted lexicographically by keys**. This makes LevelUP's <a href="#createReadStream"><code>ReadStream</code></a> interface a very powerful query mechanism.

LevelUP is designed to be backed by **[LevelDOWN](https://github.com/rvagg/node-leveldown/)** which provides a pure C++ binding to LevelDB and can be used as a stand-alone package if required.
LevelUP is designed to be backed by **[LevelDOWN](https://github.com/level/leveldown/)** which provides a pure C++ binding to LevelDB and can be used as a stand-alone package if required.
**As of version 0.9, LevelUP no longer requires LevelDOWN as a dependency so you must `npm install leveldown` when you install LevelUP.**
LevelDOWN is now optional because LevelUP can be used with alternative backends, such as **[level.js](https://github.com/maxogden/level.js)** in the browser or [MemDOWN](https://github.com/rvagg/node-memdown) for a pure in-memory store.
LevelDOWN is now optional because LevelUP can be used with alternative backends, such as **[level.js](https://github.com/maxogden/level.js)** in the browser or [MemDOWN](https://github.com/level/memdown) for a pure in-memory store.

@@ -123,3 +123,2 @@ LevelUP will look for LevelDOWN and throw an error if it can't find it in its Node `require()` path. It will also tell you if the installed version of LevelDOWN is incompatible.

* <a href="#createValueStream"><code>db.<b>createValueStream()</b></code></a>
* <a href="#createWriteStream"><code>db.<b>createWriteStream()</b></code></a>

@@ -133,3 +132,6 @@ ### Special operations exposed by LevelDOWN

### Special Notes
* <a href="#writeStreams">What happened to <code><b>db.createWriteStream()</b></code></a>
--------------------------------------------------------

@@ -166,3 +168,3 @@ <a name="ctor"></a>

The `levelup(options, callback)` form (with optional `callback`) is only available where you provide a valid `'db'` property on the options object (see below). Only for back-ends that don't require a `location` argument, such as [MemDOWN](https://github.com/rvagg/memdown).
The `levelup(options, callback)` form (with optional `callback`) is only available where you provide a valid `'db'` property on the options object (see below). Only for back-ends that don't require a `location` argument, such as [MemDOWN](https://github.com/level/memdown).

@@ -177,3 +179,3 @@ For example:

The `levelup(db, callback)` form (with optional `callback`) is only available where `db` is a factory function, as would be provided as a `'db'` property on an `options` object (see below). Only for back-ends that don't require a `location` argument, such as [MemDOWN](https://github.com/rvagg/memdown).
The `levelup(db, callback)` form (with optional `callback`) is only available where `db` is a factory function, as would be provided as a `'db'` property on an `options` object (see below). Only for back-ends that don't require a `location` argument, such as [MemDOWN](https://github.com/level/memdown).

@@ -198,3 +200,3 @@ For example:

* `'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.
* `'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.

@@ -206,3 +208,3 @@ * `'keyEncoding'` and `'valueEncoding'` *(string, default: `'utf8'`)*: The encoding of the keys and values passed through Node.js' `Buffer` implementation (see [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end)).

* `'db'` *(object, default: LevelDOWN)*: LevelUP is backed by [LevelDOWN](https://github.com/rvagg/node-leveldown/) to provide an interface to LevelDB. You can completely replace the use of LevelDOWN by providing a "factory" function that will return a LevelDOWN API compatible object given a `location` argument. For further information, see [MemDOWN](https://github.com/rvagg/node-memdown/), a fully LevelDOWN API compatible replacement that uses a memory store rather than LevelDB. Also see [Abstract LevelDOWN](http://github.com/rvagg/node-abstract-leveldown), a partial implementation of the LevelDOWN API that can be used as a base prototype for a LevelDOWN substitute.
* `'db'` *(object, default: LevelDOWN)*: LevelUP is backed by [LevelDOWN](https://github.com/level/leveldown/) to provide an interface to LevelDB. You can completely replace the use of LevelDOWN by providing a "factory" function that will return a LevelDOWN API compatible object given a `location` argument. For further information, see [MemDOWN](https://github.com/level/memdown), a fully LevelDOWN API compatible replacement that uses a memory store rather than LevelDB. Also see [Abstract LevelDOWN](http://github.com/level/abstract-leveldown), a partial implementation of the LevelDOWN API that can be used as a base prototype for a LevelDOWN substitute.

@@ -260,5 +262,5 @@ Additionally, each of the main interface methods accept an optional options object that can be used to override `'keyEncoding'` and `'valueEncoding'`.

Encoding of the `key` object will adhere to the `'keyEncoding'` option provided to <a href="#ctor"><code>levelup()</code></a>, although you can provide alternative encoding settings in the options for `get()` (it's recommended that you stay consistent in your encoding of keys and values in a single store).
Encoding of the `key` and `value` objects is the same as in <a href="#put"><code>put</code></a>.
LevelDB will by default fill the in-memory LRU Cache with data from a call to get. Disabling this is done by setting `fillCache` to `false`.
LevelDB will by default fill the in-memory LRU Cache with data from a call to get. Disabling this is done by setting `fillCache` to `false`.

@@ -269,2 +271,8 @@ --------------------------------------------------------

<code>del()</code> is the primary method for removing data from the store.
```js
db.del('foo', function (err) {
if (err)
// handle I/O or other error
});
```

@@ -462,101 +470,11 @@ #### `options`

--------------------------------------------------------
<a name="createWriteStream"></a>
### db.createWriteStream([options])
<a name="writeStreams"></a>
#### What happened to `db.createWriteStream`?
A **WriteStream** can be obtained by calling the `createWriteStream()` method. The resulting stream is a complete Node.js-style [Writable Stream](http://nodejs.org/docs/latest/api/stream.html#stream_writable_stream) which accepts objects with `'key'` and `'value'` pairs on its `write()` method.
`db.createWriteStream()` has been removed in order to provide a smaller and more maintainable core. It primarily existed to create symmetry with `db.createReadStream()` but through much [discussion](https://github.com/level/levelup/issues/199), removing it was the best cause of action.
The WriteStream will buffer writes and submit them as a `batch()` operations where writes occur *within the same tick*.
The main driver for this was performance. While `db.createReadStream()` performs well under most use cases, `db.createWriteStream()` was highly dependent on the application keys and values. Thus we can't provide a standard implementation and encourage more `write-stream` implementations to be created to solve the broad spectrum of use cases.
```js
var ws = db.createWriteStream()
Check out the implementations that the community has already produced [here](https://github.com/level/levelup/wiki/Modules#write-streams).
ws.on('error', function (err) {
console.log('Oh my!', err)
})
ws.on('close', function () {
console.log('Stream closed')
})
ws.write({ key: 'name', value: 'Yuri Irsenovich Kim' })
ws.write({ key: 'dob', value: '16 February 1941' })
ws.write({ key: 'spouse', value: 'Kim Young-sook' })
ws.write({ key: 'occupation', value: 'Clown' })
ws.end()
```
The standard `write()`, `end()`, `destroy()` and `destroySoon()` methods are implemented on the WriteStream. `'drain'`, `'error'`, `'close'` and `'pipe'` events are emitted.
You can specify encodings both for the whole stream and individual entries:
To set the encoding for the whole stream, provide an options object as the first parameter to `createWriteStream()` with `'keyEncoding'` and/or `'valueEncoding'`.
To set the encoding for an individual entry:
```js
writeStream.write({
key : new Buffer([1, 2, 3])
, value : { some: 'json' }
, keyEncoding : 'binary'
, valueEncoding : 'json'
})
```
#### write({ type: 'put' })
If individual `write()` operations are performed with a `'type'` property of `'del'`, they will be passed on as `'del'` operations to the batch.
```js
var ws = db.createWriteStream()
ws.on('error', function (err) {
console.log('Oh my!', err)
})
ws.on('close', function () {
console.log('Stream closed')
})
ws.write({ type: 'del', key: 'name' })
ws.write({ type: 'del', key: 'dob' })
ws.write({ type: 'put', key: 'spouse' })
ws.write({ type: 'del', key: 'occupation' })
ws.end()
```
#### db.createWriteStream({ type: 'del' })
If the *WriteStream* is created with a `'type'` option of `'del'`, all `write()` operations will be interpreted as `'del'`, unless explicitly specified as `'put'`.
```js
var ws = db.createWriteStream({ type: 'del' })
ws.on('error', function (err) {
console.log('Oh my!', err)
})
ws.on('close', function () {
console.log('Stream closed')
})
ws.write({ key: 'name' })
ws.write({ key: 'dob' })
// but it can be overridden
ws.write({ type: 'put', key: 'spouse', value: 'Ri Sol-ju' })
ws.write({ key: 'occupation' })
ws.end()
```
#### Pipes and Node Stream compatibility
A ReadStream can be piped directly to a WriteStream, allowing for easy copying of an entire database. A simple `copy()` operation is included in LevelUP that performs exactly this on two open databases:
```js
function copy (srcdb, dstdb, callback) {
srcdb.createReadStream().pipe(dstdb.createWriteStream()).on('close', callback)
}
```
The ReadStream is also [fstream](https://github.com/isaacs/fstream)-compatible which means you should be able to pipe to and from fstreams. So you can serialize and deserialize an entire database to a directory where keys are filenames and values are their contents, or even into a *tar* file using [node-tar](https://github.com/isaacs/node-tar). See the [fstream functional test](https://github.com/rvagg/node-levelup/blob/master/test/functional/fstream-test.js) for an example. *(Note: I'm not really sure there's a great use-case for this but it's a fun example and it helps to harden the stream implementations.)*
KeyStreams and ValueStreams can be treated like standard streams of raw data. If `'keyEncoding'` or `'valueEncoding'` is set to `'binary'` the `'data'` events will simply be standard Node `Buffer` objects straight out of the data store.
--------------------------------------------------------

@@ -576,3 +494,3 @@ <a name='approximateSize'></a>

**Note:** `approximateSize()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/), which by default is accessible as the `db` property of your LevelUP instance. This is a specific LevelDB operation and is not likely to be available where you replace LevelDOWN with an alternative back-end via the `'db'` option.
**Note:** `approximateSize()` is available via [LevelDOWN](https://github.com/level/leveldown/), which by default is accessible as the `db` property of your LevelUP instance. This is a specific LevelDB operation and is not likely to be available where you replace LevelDOWN with an alternative back-end via the `'db'` option.

@@ -600,3 +518,3 @@

**Note:** `getProperty()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/), which by default is accessible as the `db` property of your LevelUP instance. This is a specific LevelDB operation and is not likely to be available where you replace LevelDOWN with an alternative back-end via the `'db'` option.
**Note:** `getProperty()` is available via [LevelDOWN](https://github.com/level/leveldown/), which by default is accessible as the `db` property of your LevelUP instance. This is a specific LevelDB operation and is not likely to be available where you replace LevelDOWN with an alternative back-end via the `'db'` option.

@@ -611,3 +529,3 @@

**Note:** `destroy()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/) which you will have to install seperately, e.g.:
**Note:** `destroy()` is available via [LevelDOWN](https://github.com/level/leveldown/) which you will have to install seperately, e.g.:

@@ -625,3 +543,3 @@ ```js

You will find information on the *repair* operation in the *LOG* file inside the store directory.
You will find information on the *repair* operation in the *LOG* file inside the store directory.

@@ -632,3 +550,3 @@ A `repair()` can also be used to perform a compaction of the LevelDB log into table files.

**Note:** `repair()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/) which you will have to install seperately, e.g.:
**Note:** `repair()` is available via [LevelDOWN](https://github.com/level/leveldown/) which you will have to install seperately, e.g.:

@@ -682,3 +600,3 @@ ```js

A list of <a href="https://github.com/rvagg/node-levelup/wiki/Modules"><b>Node.js LevelDB modules and projects</b></a> can be found in the wiki.
A list of <a href="https://github.com/level/levelup/wiki/Modules"><b>Node.js LevelDB modules and projects</b></a> can be found in the wiki.

@@ -693,3 +611,3 @@ When attempting to extend the functionality of LevelUP, it is recommended that you consider using [level-hooks](https://github.com/dominictarr/level-hooks) and/or [level-sublevel](https://github.com/dominictarr/level-sublevel). **level-sublevel** is particularly helpful for keeping additional, extension-specific, data in a LevelDB store. It allows you to partition a LevelUP instance into multiple sub-instances that each correspond to discrete namespaced key ranges.

See the <a href="https://github.com/rvagg/node-levelup/wiki/Modules"><b>wiki</b></a> for some LevelUP extensions, including [multilevel](https://github.com/juliangruber/multilevel), that may help if you require a single data store to be shared across processes.
See the <a href="https://github.com/level/levelup/wiki/Modules"><b>wiki</b></a> for some LevelUP extensions, including [multilevel](https://github.com/juliangruber/multilevel), that may help if you require a single data store to be shared across processes.

@@ -714,3 +632,3 @@ <a name="support"></a>

See the [CONTRIBUTING.md](https://github.com/rvagg/node-levelup/blob/master/CONTRIBUTING.md) file for more details.
See the [CONTRIBUTING.md](https://github.com/level/levelup/blob/master/CONTRIBUTING.md) file for more details.

@@ -735,2 +653,3 @@ ### Contributors

<tr><th align="left">James Halliday</th><td><a href="https://github.com/substack">GitHub/substack</a></td><td><a href="https://twitter.com/substack">Twitter/@substack</a></td></tr>
<tr><th align="left">Jarrett Cruger</th><td><a href="https://github.com/jcrugzz">GitHub/jcrugzz</a></td><td><a href="https://twitter.com/jcrugzz">Twitter/@jcrugzz</a></td></tr>
</tbody></table>

@@ -747,3 +666,3 @@

Copyright (c) 2012-2014 LevelUP contributors (listed above).
Copyright (c) 2012-2015 LevelUP contributors (listed above).

@@ -750,0 +669,0 @@ LevelUP is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -46,12 +46,6 @@

db.put.bind(db)
, { name: 'WriteError', message: 'put() requires key and value arguments' }
, { name: 'WriteError', message: 'put() requires a key argument' }
, 'no-arg put() throws'
)
assert.exception(
db.put.bind(db, 'foo')
, { name: 'WriteError', message: 'put() requires key and value arguments' }
, 'callback-less, 1-arg put() throws'
)
done()

@@ -58,0 +52,0 @@ })

@@ -1,7 +0,8 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var errors = require('../lib/errors.js')
var levelup = require('../lib/levelup')
, errors = levelup.errors
, async = require('async')

@@ -250,19 +251,5 @@ , common = require('./common')

// value = undefined
assert.exception(this.batch.put.bind(this.batch, 'foo1'), function (err) {
console.log('err.name', err.name, 'err.message', err.message)
if (err.name != 'WriteError')
return false
if ('value cannot be `null` or `undefined`' != err.message)
return false
return true
})
this.batch.put('foo1')
// value = null
assert.exception(this.batch.put.bind(this.batch, 'foo1', null), function (err) {
if (err.name != 'WriteError')
return false
if ('value cannot be `null` or `undefined`' != err.message)
return false
return true
})
this.batch.put('foo1', null)
}

@@ -269,0 +256,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -31,7 +31,7 @@

, 'test put() and get() with binary value {encoding:binary}': function (done) {
, 'test put() and get() with binary value {valueEncoding:binary}': function (done) {
this.openTestDatabase(function (db) {
db.put('binarydata', this.testData, { encoding: 'binary' }, function (err) {
db.put('binarydata', this.testData, { valueEncoding: 'binary' }, function (err) {
refute(err)
db.get('binarydata', { encoding: 'binary' }, function (err, value) {
db.get('binarydata', { valueEncoding: 'binary' }, function (err, value) {
refute(err)

@@ -45,4 +45,4 @@ assert(value)

, 'test put() and get() with binary value {encoding:binary} on createDatabase()': function (done) {
this.openTestDatabase({ createIfMissing: true, errorIfExists: true, encoding: 'binary' }, function (db) {
, 'test put() and get() with binary value {valueEncoding:binary} on createDatabase()': function (done) {
this.openTestDatabase({ createIfMissing: true, errorIfExists: true, valueEncoding: 'binary' }, function (db) {
db.put('binarydata', this.testData, function (err) {

@@ -59,7 +59,7 @@ refute(err)

, 'test put() and get() with binary key {encoding:binary}': function (done) {
, 'test put() and get() with binary key {valueEncoding:binary}': function (done) {
this.openTestDatabase(function (db) {
db.put(this.testData, 'binarydata', { encoding: 'binary' }, function (err) {
db.put(this.testData, 'binarydata', { valueEncoding: 'binary' }, function (err) {
refute(err)
db.get(this.testData, { encoding: 'binary' }, function (err, value) {
db.get(this.testData, { valueEncoding: 'binary' }, function (err, value) {
refute(err)

@@ -113,7 +113,7 @@ assert(value instanceof Buffer, 'value is buffer')

, 'test put() and get() with binary key & value {encoding:binary}': function (done) {
, 'test put() and get() with binary key & value {valueEncoding:binary}': function (done) {
this.openTestDatabase(function (db) {
db.put(this.testData, this.testData, { encoding: 'binary' }, function (err) {
db.put(this.testData, this.testData, { valueEncoding: 'binary' }, function (err) {
refute(err)
db.get(this.testData, { encoding: 'binary' }, function (err, value) {
db.get(this.testData, { valueEncoding: 'binary' }, function (err, value) {
refute(err)

@@ -127,9 +127,9 @@ common.checkBinaryTestData(value, done)

, 'test put() and del() and get() with binary key {encoding:binary}': function (done) {
, 'test put() and del() and get() with binary key {valueEncoding:binary}': function (done) {
this.openTestDatabase(function (db) {
db.put(this.testData, 'binarydata', { encoding: 'binary' }, function (err) {
db.put(this.testData, 'binarydata', { valueEncoding: 'binary' }, function (err) {
refute(err)
db.del(this.testData, { encoding: 'binary' }, function (err) {
db.del(this.testData, { valueEncoding: 'binary' }, function (err) {
refute(err)
db.get(this.testData, { encoding: 'binary' }, function (err, value) {
db.get(this.testData, { valueEncoding: 'binary' }, function (err, value) {
assert(err)

@@ -158,3 +158,3 @@ refute(value)

, function (key, callback) {
db.get(key, { encoding: 'binary' }, function (err, value) {
db.get(key, { valueEncoding: 'binary' }, function (err, value) {
refute(err)

@@ -161,0 +161,0 @@ if (key == 'baz') {

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -16,4 +16,7 @@

, levelup = require('../lib/levelup.js')
, errors = require('level-errors')
, dbidx = 0
assert(levelup.errors === errors);
referee.add('isInstanceOf', {

@@ -20,0 +23,0 @@ assert: function (actual, expected) {

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -21,3 +21,3 @@

// 1) open database without callback, opens in worker thread
, db = levelup(location, { createIfMissing: true, errorIfExists: true, encoding: 'utf8' })
, db = levelup(location, { createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8' })

@@ -65,3 +65,3 @@ this.closeableDatabases.push(db)

// 1) open database without callback, opens in worker thread
, db = levelup(location, { createIfMissing: true, errorIfExists: true, encoding: 'utf8' })
, db = levelup(location, { createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8' })

@@ -109,3 +109,3 @@ this.closeableDatabases.push(db)

// 1) open database without callback, opens in worker thread
, db = levelup(location, { createIfMissing: true, errorIfExists: true, encoding: 'utf8' })
, db = levelup(location, { createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8' })

@@ -175,3 +175,3 @@ this.closeableDatabases.push(db)

// 1) open database without callback, opens in worker thread
, db = levelup(location, { createIfMissing: true, errorIfExists: true, encoding: 'utf8' })
, db = levelup(location, { createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8' })
, stderrMock = this.mock(console)

@@ -178,0 +178,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -19,3 +19,3 @@

this.openTestDatabase(
{ createIfMissing: true, errorIfExists: true, encoding: 'utf8' }
{ createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8' }
, function (db) {

@@ -41,3 +41,3 @@ db.put('foo', 'this {} is [] not : json', function (err) {

this.openTestDatabase(
{ createIfMissing: true, errorIfExists: true, encoding: 'utf8' }
{ createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8' }
, function (db) {

@@ -72,3 +72,3 @@ db.put('foo', 'this {} is [] not : json', function (err) {

// the key is not encoded as JSON
this.openTestDatabase({ encoding: 'json' }, function (db) {
this.openTestDatabase({ valueEncoding: 'json' }, function (db) {
db.put('foo:foo', { bar: 'bar' }, function (err) {

@@ -84,49 +84,4 @@ refute(err)

}
, 'test write-stream encoding': function (done) {
this.openTestDatabase({ encoding: 'json' }, function (db) {
var ws = db.createWriteStream({
keyEncoding : 'utf8',
valueEncoding : 'binary'
})
ws.on('close', function () {
db.get('foo', {
keyEncoding : 'utf8',
valueEncoding : 'binary'
}, function (err, val) {
refute(err)
assert.equals(val.toString(), '\u0001\u0002\u0003')
db.close(done)
})
})
ws.write({ key : 'foo', value : new Buffer([1, 2, 3]) })
ws.end()
})
}
, 'test write-stream chunk encoding': function (done) {
this.openTestDatabase({ encoding: 'json' }, function (db) {
var ws = db.createWriteStream({
keyEncoding : 'utf8',
valueEncoding : 'binary'
})
ws.on('close', function () {
db.get(new Buffer([1, 2, 3]), {
keyEncoding : 'binary',
valueEncoding : 'json'
}, function (err, val) {
refute(err)
assert.equals(val.some, 'json')
db.close(done)
})
})
ws.write({
key : new Buffer([1, 2, 3]),
value : { some : 'json' },
keyEncoding : 'binary',
valueEncoding : 'json'
})
ws.end()
})
}
, 'test batch op encoding': function (done) {
this.openTestDatabase({ encoding: 'json' }, function (db) {
this.openTestDatabase({ valueEncoding: 'json' }, function (db) {
db.batch([

@@ -133,0 +88,0 @@ {

@@ -1,7 +0,8 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var errors = require('../lib/errors.js')
var levelup = require('../lib/levelup.js')
, errors = levelup.errors
, async = require('async')

@@ -128,12 +129,6 @@ , common = require('./common')

db.put.bind(db)
, { name: 'WriteError', message: 'put() requires key and value arguments' }
, { name: 'WriteError', message: 'put() requires a key argument' }
, 'no-arg put() throws'
)
assert.exception(
db.put.bind(db, 'foo')
, { name: 'WriteError', message: 'put() requires key and value arguments' }
, 'callback-less, 1-arg put() throws'
)
done()

@@ -140,0 +135,0 @@ })

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

@@ -1,8 +0,8 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var levelup = require('../lib/levelup.js')
, errors = require('../lib/errors.js')
, errors = levelup.errors
, fs = require('fs')

@@ -61,3 +61,3 @@ , common = require('./common')

location
, { createIfMissing: true, errorIfExists: true, encoding: 'binary' }
, { createIfMissing: true, errorIfExists: true, valueEncoding: 'binary' }
, function (err, db) {

@@ -64,0 +64,0 @@ refute(err)

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -25,3 +25,3 @@

errorIfExists: true,
encoding: {
valueEncoding: {
encode: msgpack.encode,

@@ -28,0 +28,0 @@ decode: msgpack.decode,

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -20,3 +20,3 @@

this.cleanupDirs.push(location)
levelup(location, { createIfMissing: true, errorIfExists: true, encoding: {encode: JSON.stringify, decode: JSON.parse }}, function (err, db) {
levelup(location, { createIfMissing: true, errorIfExists: true, valueEncoding: {encode: JSON.stringify, decode: JSON.parse }}, function (err, db) {
refute(err)

@@ -23,0 +23,0 @@ if (err) return

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -49,3 +49,3 @@

assert.equals(
md._keys
md._store['$foo'].keys
, expected.map(function (e) { return e.key })

@@ -52,0 +52,0 @@ , 'memdown has the entries'

@@ -1,8 +0,8 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var levelup = require('../lib/levelup.js')
, errors = require('../lib/errors.js')
, errors = levelup.errors
, common = require('./common')

@@ -83,7 +83,5 @@

, 'put() with null value causes error': function (done) {
, 'put() with null value works': function (done) {
this.db.put('foo', null, function (err, value) {
refute(value)
assert.isInstanceOf(err, Error)
assert.isInstanceOf(err, errors.LevelUPError)
refute(err)
done()

@@ -93,23 +91,19 @@ })

, 'put() with undefined value causes error': function (done) {
, 'put() with undefined value works': function (done) {
this.db.put('foo', undefined, function (err, value) {
refute(value)
assert.isInstanceOf(err, Error)
assert.isInstanceOf(err, errors.LevelUPError)
refute(err)
done()
})
}
, 'batch() with undefined value causes error': function (done) {
, 'batch() with undefined value works': function (done) {
this.db.batch([{key: 'foo', value: undefined, type: 'put'}]
, function (err) {
assert.isInstanceOf(err, Error)
assert.isInstanceOf(err, errors.LevelUPError)
refute(err)
done()
})
}
, 'batch() with null value causes error': function (done) {
, 'batch() with null value works': function (done) {
this.db.batch([{key: 'foo', value: null, type: 'put'}]
, function (err) {
assert.isInstanceOf(err, Error)
assert.isInstanceOf(err, errors.LevelUPError)
refute(err)
done()

@@ -116,0 +110,0 @@ })

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -17,3 +17,3 @@

// 1) open database without callback, opens in worker thread
, db = levelup(location, { createIfMissing: true, errorIfExists: true, encoding: 'utf8'})
, db = levelup(location, { createIfMissing: true, errorIfExists: true, valueEncoding: 'utf8'})

@@ -20,0 +20,0 @@ this.closeableDatabases.push(db)

@@ -1,10 +0,11 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/
var assert = require('referee').assert
var levelup = require('../lib/levelup')
, assert = require('referee').assert
, refute = require('referee').refute
, buster = require('bustermove')
, errors = require('../lib/errors')
, errors = levelup.errors

@@ -11,0 +12,0 @@ function clearCache () {

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -561,3 +561,3 @@

refute(err)
var db2 = levelup(db.location, { createIfMissing: false, errorIfExists: false, encoding: 'utf8' })
var db2 = levelup(db.location, { createIfMissing: false, errorIfExists: false, valueEncoding: 'utf8' })
execute(db2)

@@ -679,3 +679,3 @@ })

// modules
// see: https://github.com/rvagg/node-levelup/issues/216
// see: https://github.com/level/levelup/issues/216

@@ -682,0 +682,0 @@ assert(

@@ -1,4 +0,4 @@

/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
/* Copyright (c) 2012-2015 LevelUP contributors
* See list at <https://github.com/level/levelup#contributing>
* MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
*/

@@ -5,0 +5,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc