Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

abstract-leveldown

Level7.5mMITdeprecated7.2.0TypeScript support: definitely-typed

Superseded by abstract-level (https://github.com/Level/community#faq)

An abstract prototype matching the LevelDOWN API

level, leveldb, leveldown, levelup

readme

abstract-leveldown

An abstract prototype matching the leveldown]leveldown API. Useful for extending [levelup functionality by providing a replacement to leveldown.

level badge npm Node version Test Coverage Standard Common Changelog Donate

Table of Contents

<summary>Click to expand</summary>

Background

This module provides a simple base prototype for a key-value store. It has a public API for consumers and a private API for implementors. To implement a abstract-leveldown compliant store, extend its prototype and override the private underscore versions of the methods. For example, to implement put(), override _put() on your prototype.

Where possible, the default private methods have sensible noop defaults that essentially do nothing. For example, _open(callback) will invoke callback on a next tick. Other methods like _clear(..) have functional defaults. Each method listed below documents whether implementing it is mandatory.

The private methods are always provided with consistent arguments, regardless of what is passed in through the public API. All public methods provide argument checking: if a consumer calls open() without a callback argument they'll get an Error('open() requires a callback argument').

Where optional arguments are involved, private methods receive sensible defaults: a get(key, callback) call translates to _get(key, options, callback) where the options argument is an empty object. These arguments are documented below.

If you are upgrading: please see UPGRADING.md.

Example

Let's implement a simplistic in-memory leveldown replacement:

var AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN
var util = require('util')

// Constructor
function FakeLevelDOWN () {
  AbstractLevelDOWN.call(this)
}

// Our new prototype inherits from AbstractLevelDOWN
util.inherits(FakeLevelDOWN, AbstractLevelDOWN)

FakeLevelDOWN.prototype._open = function (options, callback) {
  // Initialize a memory storage object
  this._store = {}

  // Use nextTick to be a nice async citizen
  this._nextTick(callback)
}

FakeLevelDOWN.prototype._serializeKey = function (key) {
  // As an example, prefix all input keys with an exclamation mark.
  // Below methods will receive serialized keys in their arguments.
  return '!' + key
}

FakeLevelDOWN.prototype._put = function (key, value, options, callback) {
  this._store[key] = value
  this._nextTick(callback)
}

FakeLevelDOWN.prototype._get = function (key, options, callback) {
  var value = this._store[key]

  if (value === undefined) {
    // 'NotFound' error, consistent with LevelDOWN API
    return this._nextTick(callback, new Error('NotFound'))
  }

  this._nextTick(callback, null, value)
}

FakeLevelDOWN.prototype._del = function (key, options, callback) {
  delete this._store[key]
  this._nextTick(callback)
}

Now we can use our implementation with levelup:

var levelup = require('levelup')

var db = levelup(new FakeLevelDOWN())

db.put('foo', 'bar', function (err) {
  if (err) throw err

  db.get('foo', function (err, value) {
    if (err) throw err

    console.log(value) // 'bar'
  })
})

See memdown if you are looking for a complete in-memory replacement for leveldown.

Browser Support

Sauce Test Status

Public API For Consumers

db = constructor(..)

Constructors typically take a location argument pointing to a location on disk where the data will be stored. Since not all implementations are disk-based and some are non-persistent, implementors are free to take zero or more arguments in their constructor.

db.status

A read-only property. An abstract-leveldown compliant store can be in one of the following states:

  • 'new' - newly created, not opened or closed
  • 'opening' - waiting for the store to be opened
  • 'open' - successfully opened the store, available for use
  • 'closing' - waiting for the store to be closed
  • 'closed' - store has been successfully closed, should not be used.

db.supports

A read-only manifest. Might be used like so:

if (!db.supports.permanence) {
  throw new Error('Persistent storage is required')
}

if (db.supports.bufferKeys && db.supports.promises) {
  await db.put(Buffer.from('key'), 'value')
}

db.open([options, ]callback)

Open the store. The callback function will be called with no arguments when the store has been successfully opened, or with a single error argument if the open operation failed for any reason.

The optional options argument may contain:

  • createIfMissing (boolean, default: true): If true and the store doesn't exist it will be created. If false and the store doesn't exist, callback will receive an error.
  • errorIfExists (boolean, default: false): If true and the store exists, callback will receive an error.

Not all implementations support the above options.

db.close(callback)

Close the store. The callback function will be called with no arguments if the operation is successful or with a single error argument if closing failed for any reason.

db.get(key[, options], callback)

Get a value from the store by key. The optional options object may contain:

  • asBuffer (boolean, default: true): Whether to return the value as a Buffer. If false, the returned type depends on the implementation.

The callback function will be called with an Error if the operation failed for any reason, including if the key was not found. If successful the first argument will be null and the second argument will be the value.

db.getMany(keys[, options][, callback])

Get multiple values from the store by an array of keys. The optional options object may contain:

  • asBuffer (boolean, default: true): Whether to return the value as a Buffer. If false, the returned type depends on the implementation.

The callback function will be called with an Error if the operation failed for any reason. If successful the first argument will be null and the second argument will be an array of values with the same order as keys. If a key was not found, the relevant value will be undefined.

If no callback is provided, a promise is returned.

db.put(key, value[, options], callback)

Store a new entry or overwrite an existing entry. There are no options by default but implementations may add theirs. The callback function will be called with no arguments if the operation is successful or with an Error if putting failed for any reason.

db.del(key[, options], callback)

Delete an entry. There are no options by default but implementations may add theirs. The callback function will be called with no arguments if the operation is successful or with an Error if deletion failed for any reason.

db.batch(operations[, options], callback)

Perform multiple put and/or del operations in bulk. The operations argument must be an Array containing a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation.

Each operation is contained in an object having the following properties: type, key, value, where the type is either 'put' or 'del'. In the case of 'del' the value property is ignored.

There are no options by default but implementations may add theirs. The callback function will be called with no arguments if the batch is successful or with an Error if the batch failed for any reason.

db.batch()

Returns a chainedBatch.

db.iterator([options])

Returns an iterator. Accepts the following range options:

  • gt (greater than), gte (greater than or equal) define the lower bound of the range to be iterated. Only entries where the key is greater than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the entries iterated will be the same.
  • lt (less than), lte (less than or equal) define the higher bound of the range to be iterated. Only entries where the key is less than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the entries iterated will be the same.
  • reverse (boolean, default: false): iterate entries in reverse order. Beware that a reverse seek can be slower than a forward seek.
  • limit (number, default: -1): limit the number of entries collected by this iterator. This number represents a maximum number of entries and may not be reached if you get to the end of the range first. A value of -1 means there is no limit. When reverse=true the entries with the highest keys will be returned instead of the lowest keys.

Note Zero-length strings, buffers and arrays as well as null and undefined are invalid as keys, yet valid as range options. These types are significant in encodings like bytewise and charwise as well as some underlying stores like IndexedDB. Consumers of an implementation should assume that { gt: undefined } is not the same as {}. An implementation can choose to:

  • Serialize or encode these types to make them meaningful
  • Have no defined behavior (moving the concern to a higher level)
  • Delegate to an underlying store (moving the concern to a lower level).

If you are an implementor, a final note: the abstract test suite does not test these types. Whether they are supported or how they sort is up to you; add custom tests accordingly.

In addition to range options, iterator() takes the following options:

  • keys (boolean, default: true): whether to return the key of each entry. If set to false, calls to iterator.next(callback) will yield keys with a value of undefined.
  • values (boolean, default: true): whether to return the value of each entry. If set to false, calls to iterator.next(callback) will yield values with a value of undefined.
  • keyAsBuffer (boolean, default: true): Whether to return the key of each entry as a Buffer. If false, the returned type depends on the implementation.
  • valueAsBuffer (boolean, default: true): Whether to return the value of each entry as a Buffer.

Lastly, an implementation is free to add its own options.

db.clear([options, ]callback)

This method is experimental. Not all implementations support it yet.

Delete all entries or a range. Not guaranteed to be atomic. Accepts the following range options (with the same rules as on iterators):

  • gt (greater than), gte (greater than or equal) define the lower bound of the range to be deleted. Only entries where the key is greater than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the entries deleted will be the same.
  • lt (less than), lte (less than or equal) define the higher bound of the range to be deleted. Only entries where the key is less than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the entries deleted will be the same.
  • reverse (boolean, default: false): delete entries in reverse order. Only effective in combination with limit, to remove the last N records.
  • limit (number, default: -1): limit the number of entries to be deleted. This number represents a maximum number of entries and may not be reached if you get to the end of the range first. A value of -1 means there is no limit. When reverse=true the entries with the highest keys will be deleted instead of the lowest keys.

If no options are provided, all entries will be deleted. The callback function will be called with no arguments if the operation was successful or with an Error if it failed for any reason.

chainedBatch

chainedBatch.put(key, value[, options])

Queue a put operation on this batch. This may throw if key or value is invalid. There are no options by default but implementations may add theirs.

chainedBatch.del(key[, options])

Queue a del operation on this batch. This may throw if key is invalid. There are no options by default but implementations may add theirs.

chainedBatch.clear()

Clear all queued operations on this batch.

chainedBatch.write([options, ]callback)

Commit the queued operations for this batch. All operations will be written atomically, that is, they will either all succeed or fail with no partial commits.

There are no options by default but implementations may add theirs. The callback function will be called with no arguments if the batch is successful or with an Error if the batch failed for any reason.

After write has been called, no further operations are allowed.

chainedBatch.db

A reference to the db that created this chained batch.

iterator

An iterator allows you to iterate the entire store or a range. It operates on a snapshot of the store, created at the time db.iterator() was called. This means reads on the iterator are unaffected by simultaneous writes. Most but not all implementations can offer this guarantee.

Iterators can be consumed with for await...of or by manually calling iterator.next() in succession. In the latter mode, iterator.end() must always be called. In contrast, finishing, throwing or breaking from a for await...of loop automatically calls iterator.end().

An iterator reaches its natural end in the following situations:

  • The end of the store has been reached
  • The end of the range has been reached
  • The last iterator.seek() was out of range.

An iterator keeps track of when a next() is in progress and when an end() has been called so it doesn't allow concurrent next() calls, it does allow end() while a next() is in progress and it doesn't allow either next() or end() after end() has been called.

for await...of iterator

Yields arrays containing a key and value. The type of key and value depends on the options passed to db.iterator().

try {
  for await (const [key, value] of db.iterator()) {
    console.log(key)
  }
} catch (err) {
  console.error(err)
}

Note for implementors: this uses iterator.next() and iterator.end() under the hood so no further method implementations are needed to support for await...of.

iterator.next([callback])

Advance the iterator and yield the entry at that key. If an error occurs, the callback function will be called with an Error. Otherwise, the callback receives null, a key and a value. The type of key and value depends on the options passed to db.iterator(). If the iterator has reached its natural end, both key and value will be undefined.

If no callback is provided, a promise is returned for either an array (containing a key and value) or undefined if the iterator reached its natural end.

Note: Always call iterator.end(), even if you received an error and even if the iterator reached its natural end.

iterator.seek(target)

Seek the iterator to a given key or the closest key. Subsequent calls to iterator.next() (including implicit calls in a for await...of loop) will yield entries with keys equal to or larger than target, or equal to or smaller than target if the reverse option passed to db.iterator() was true.

If range options like gt were passed to db.iterator() and target does not fall within that range, the iterator will reach its natural end.

Note: At the time of writing, leveldown is the only known implementation to support seek(). In other implementations, it is a noop.

iterator.end([callback])

End iteration and free up underlying resources. The callback function will be called with no arguments on success or with an Error if ending failed for any reason.

If no callback is provided, a promise is returned.

iterator.db

A reference to the db that created this iterator.

Type Support

The following applies to any method above that takes a key argument or option: all implementations must support a key of type String and should support a key of type Buffer. A key may not be null, undefined, a zero-length Buffer, zero-length string or zero-length array.

The following applies to any method above that takes a value argument or option: all implementations must support a value of type String or Buffer. A value may not be null or undefined due to preexisting significance in streams and iterators.

Support of other key and value types depends on the implementation as well as its underlying storage. See also db._serializeKey and db._serializeValue.

Private API For Implementors

Each of these methods will receive exactly the number and order of arguments described. Optional arguments will receive sensible defaults. All callbacks are error-first and must be asynchronous.

If an operation within your implementation is synchronous, be sure to invoke the callback on a next tick using queueMicrotask, process.nextTick or some other means of microtask scheduling. For convenience, the prototypes of AbstractLevelDOWN, AbstractIterator and AbstractChainedBatch include a _nextTick method that is compatible with node and browsers.

db = AbstractLevelDOWN([manifest])

The constructor. Sets the .status to 'new'. Optionally takes a manifest object which abstract-leveldown will enrich:

AbstractLevelDOWN.call(this, {
  bufferKeys: true,
  snapshots: true,
  // ..
})

db._open(options, callback)

Open the store. The options object will always have the following properties: createIfMissing, errorIfExists. If opening failed, call the callback function with an Error. Otherwise call callback without any arguments.

The default _open() is a sensible noop and invokes callback on a next tick.

db._close(callback)

Close the store. If closing failed, call the callback function with an Error. Otherwise call callback without any arguments.

The default _close() is a sensible noop and invokes callback on a next tick.

db._serializeKey(key)

Convert a key to a type supported by the underlying storage. All methods below that take a key argument or option - including db._iterator() with its range options and iterator._seek() with its target argument - will receive serialized keys. For example, if _serializeKey is implemented as:

FakeLevelDOWN.prototype._serializeKey = function (key) {
  return Buffer.isBuffer(key) ? key : String(key)
}

Then db.get(2, callback) translates into db._get('2', options, callback). Similarly, db.iterator({ gt: 2 }) translates into db._iterator({ gt: '2', ... }) and iterator.seek(2) translates into iterator._seek('2').

If the underlying storage supports any JavaScript type or if your implementation wraps another implementation, it is recommended to make _serializeKey an identity function (returning the key as-is). Serialization is irreversible, unlike encoding as performed by implementations like encoding-down. This also applies to _serializeValue.

The default _serializeKey() is an identity function.

db._serializeValue(value)

Convert a value to a type supported by the underlying storage. All methods below that take a value argument or option will receive serialized values. For example, if _serializeValue is implemented as:

FakeLevelDOWN.prototype._serializeValue = function (value) {
  return Buffer.isBuffer(value) ? value : String(value)
}

Then db.put(key, 2, callback) translates into db._put(key, '2', options, callback).

The default _serializeValue() is an identity function.

db._get(key, options, callback)

Get a value by key. The options object will always have the following properties: asBuffer. If the key does not exist, call the callback function with a new Error('NotFound'). Otherwise call callback with null as the first argument and the value as the second.

The default _get() invokes callback on a next tick with a NotFound error. It must be overridden.

db._getMany(keys, options, callback)

This new method is optional for the time being. To enable its tests, set the getMany option of the test suite to true.

Get multiple values by an array of keys. The options object will always have the following properties: asBuffer. If an error occurs, call the callback function with an Error. Otherwise call callback with null as the first argument and an array of values as the second. If a key does not exist, set the relevant value to undefined.

The default _getMany() invokes callback on a next tick with an array of values that is equal in length to keys and is filled with undefined. It must be overridden to support getMany() but this is currently an opt-in feature. If the implementation does support getMany() then db.supports.getMany must be set to true via the constructor.

db._put(key, value, options, callback)

Store a new entry or overwrite an existing entry. There are no default options but options will always be an object. If putting failed, call the callback function with an Error. Otherwise call callback without any arguments.

The default _put() invokes callback on a next tick. It must be overridden.

db._del(key, options, callback)

Delete an entry. There are no default options but options will always be an object. If deletion failed, call the callback function with an Error. Otherwise call callback without any arguments.

The default _del() invokes callback on a next tick. It must be overridden.

db._batch(operations, options, callback)

Perform multiple put and/or del operations in bulk. The operations argument is always an Array containing a list of operations to be executed sequentially, although as a whole they should be performed as an atomic operation. Each operation is guaranteed to have at least type and key properties. There are no default options but options will always be an object. If the batch failed, call the callback function with an Error. Otherwise call callback without any arguments.

The default _batch() invokes callback on a next tick. It must be overridden.

db._chainedBatch()

The default _chainedBatch() returns a functional AbstractChainedBatch instance that uses db._batch(array, options, callback) under the hood. The prototype is available on the main exports for you to extend. If you want to implement chainable batch operations in a different manner then you should extend AbstractChainedBatch and return an instance of this prototype in the _chainedBatch() method:

var AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch
var inherits = require('util').inherits

function ChainedBatch (db) {
  AbstractChainedBatch.call(this, db)
}

inherits(ChainedBatch, AbstractChainedBatch)

FakeLevelDOWN.prototype._chainedBatch = function () {
  return new ChainedBatch(this)
}

db._iterator(options)

The default _iterator() returns a noop AbstractIterator instance. It must be overridden, by extending AbstractIterator (available on the main module exports) and returning an instance of this prototype in the _iterator(options) method.

The options object will always have the following properties: reverse, keys, values, limit, keyAsBuffer and valueAsBuffer.

db._clear(options, callback)

This method is experimental and optional for the time being. To enable its tests, set the clear option of the test suite to true.

Delete all entries or a range. Does not have to be atomic. It is recommended (and possibly mandatory in the future) to operate on a snapshot so that writes scheduled after a call to clear() will not be affected.

The default _clear() uses _iterator() and _del() to provide a reasonable fallback, but requires binary key support. It is recommended to implement _clear() with more performant primitives than _iterator() and _del() if the underlying storage has such primitives. Implementations that don't support binary keys must implement their own _clear().

Implementations that wrap another db can typically forward the _clear() call to that db, having transformed range options if necessary.

The options object will always have the following properties: reverse and limit.

iterator = AbstractIterator(db)

The first argument to this constructor must be an instance of your AbstractLevelDOWN implementation. The constructor will set iterator.db which is used to access db._serialize* and ensures that db will not be garbage collected in case there are no other references to it.

iterator._next(callback)

Advance the iterator and yield the entry at that key. If nexting failed, call the callback function with an Error. Otherwise, call callback with null, a key and a value.

The default _next() invokes callback on a next tick. It must be overridden.

iterator._seek(target)

Seek the iterator to a given key or the closest key. This method is optional.

iterator._end(callback)

Free up underlying resources. This method is guaranteed to only be called once. If ending failed, call the callback function with an Error. Otherwise call callback without any arguments.

The default _end() invokes callback on a next tick. Overriding is optional.

chainedBatch = AbstractChainedBatch(db)

The first argument to this constructor must be an instance of your AbstractLevelDOWN implementation. The constructor will set chainedBatch.db which is used to access db._serialize* and ensures that db will not be garbage collected in case there are no other references to it.

chainedBatch._put(key, value, options)

Queue a put operation on this batch. There are no default options but options will always be an object.

chainedBatch._del(key, options)

Queue a del operation on this batch. There are no default options but options will always be an object.

chainedBatch._clear()

Clear all queued operations on this batch.

chainedBatch._write(options, callback)

The default _write method uses db._batch. If the _write method is overridden it must atomically commit the queued operations. There are no default options but options will always be an object. If committing fails, call the callback function with an Error. Otherwise call callback without any arguments.

Test Suite

To prove that your implementation is abstract-leveldown compliant, include the abstract test suite in your test.js (or similar):

const test = require('tape')
const suite = require('abstract-leveldown/test')
const YourDOWN = require('.')

suite({
  test: test,
  factory: function () {
    return new YourDOWN()
  }
})

This is the most minimal setup. The test option must be a function that is API-compatible with tape. The factory option must be a function that returns a unique and isolated database instance. The factory will be called many times by the test suite.

If your implementation is disk-based we recommend using tempy (or similar) to create unique temporary directories. Your setup could look something like:

const test = require('tape')
const tempy = require('tempy')
const suite = require('abstract-leveldown/test')
const YourDOWN = require('.')

suite({
  test: test,
  factory: function () {
    return new YourDOWN(tempy.directory())
  }
})

Excluding tests

As not every implementation can be fully compliant due to limitations of its underlying storage, some tests may be skipped. For example, to skip snapshot tests:

suite({
  // ..
  snapshots: false
})

This also serves as a signal to users of your implementation. The following options are available:

  • bufferKeys: set to false if binary keys are not supported by the underlying storage
  • seek: set to false if your iterator does not implement _seek
  • clear: defaults to false until a next major release. Set to true if your implementation either implements _clear() itself or is suitable to use the default implementation of _clear() (which requires binary key support).
  • getMany: defaults to false until a next major release. Set to true if your implementation implements _getMany().
  • snapshots: set to false if any of the following is true:
    • Reads don't operate on a snapshot
    • Snapshots are created asynchronously
  • createIfMissing and errorIfExists: set to false if db._open() does not support these options.

This metadata will be moved to manifests (db.supports) in the future.

Setup and teardown

To perform (a)synchronous work before or after each test, you may define setUp and tearDown functions:

suite({
  // ..
  setUp: function (t) {
    t.end()
  },
  tearDown: function (t) {
    t.end()
  }
})

Reusing testCommon

The input to the test suite is a testCommon object. Should you need to reuse testCommon for your own (additional) tests, use the included utility to create a testCommon with defaults:

const test = require('tape')
const suite = require('abstract-leveldown/test')
const YourDOWN = require('.')

const testCommon = suite.common({
  test: test,
  factory: function () {
    return new YourDOWN()
  }
})

suite(testCommon)

The testCommon object will have all the properties describe above: test, factory, setUp, tearDown and the skip options. You might use it like so:

test('setUp', testCommon.setUp)

test('custom test', function (t) {
  var db = testCommon.factory()
  // ..
})

test('another custom test', function (t) {
  var db = testCommon.factory()
  // ..
})

test('tearDown', testCommon.tearDown)

Spread The Word

If you'd like to share your awesome implementation with the world, here's what you might want to do:

  • Add an awesome badge to your README: ![level badge](https://leveljs.org/img/badge.svg)
  • Publish your awesome module to npm
  • Send a Pull Request to Level/awesome to advertise your work!

Install

With npm do:

npm install abstract-leveldown

Contributing

Level/abstract-leveldown is an OPEN Open Source Project. This means that:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the Contribution Guide for more details.

Big Thanks

Cross-browser Testing Platform and Open Source ♥ Provided by Sauce Labs.

Sauce Labs logo

Support us with a monthly donation on Open Collective and help us continue our work.

License

MIT

changelog

Changelog

7.2.0 - 2021-09-28

Added

  • Add db.getMany(keys) (#381) (e4445a7) (Vincent Weevers).

7.1.0 - 2021-09-21

Added

  • Support for await...of db.iterator() (#379) (372695f) (Vincent Weevers)

7.0.0 - 2021-04-09

If you are upgrading: please see UPGRADING.md.

Changed

  • Replace immediate shim with smaller queue-microtask (a00e3ed) (Vincent Weevers).
  • Remove need for full buffer shim (except in test suite) (8f79234) (Vincent Weevers)
  • Bump level-concat-iterator and level-supports (0b5e1a3) (Vincent Weevers)
  • Breaking: drop support of Safari 11 (7c4cce6) (Vincent Weevers)
  • Modernize syntax and bump standard from 14.x to 16.x (cfe8040) (Vincent Weevers)
  • Replace xtend dependency with Object.assign() (9d4171f) (Vincent Weevers)
  • Breaking: remove legacy range options (start & end) (979d34f) (Level/community#86) (Vincent Weevers)
  • Breaking: drop support of stock Android browser (AOSP) (a1fd94e) (Vincent Weevers)
  • Breaking: drop node 6 and 8 (1beee24) (Vincent Weevers)
  • Breaking (for browsers): bump buffer from 5.x to 6.x (#373) (f62f38b) (Alex Potsides).

Added

6.3.0 - 2020-04-11

Changed

  • Upgrade devDependency dependency-check from ^3.3.0 to ^4.1.0 (9193656) (@vweevers)

Added

  • Support running test suite on a levelup db, as well as skipping start and end tests (for multileveldown) (#364) (@vweevers)

6.2.3 - 2020-04-03

Changed

  • Upgrade airtap devDependency from ^2.0.0 to ^3.0.0 (#360) (@vweevers)

Fixed

6.2.2 - 2019-10-21

Added

6.2.1 - 2019-10-01

Fixed

6.2.0 - 2019-09-30

Changed

  • Upgrade hallmark devDependency from ^1.0.0 to ^2.0.0 (#349) (@vweevers)
  • Upgrade standard devDependency from ^13.0.1 to ^14.0.0 (#348) (@vweevers)

Added

6.1.1 - 2019-08-18

Fixed

  • Remove process.emitWarning because it breaks AppVeyor builds (8e963c3) (@vweevers)

6.1.0 - 2019-08-18

Changed

  • Upgrade hallmark devDependency from ^0.1.0 to ^1.0.0 (#343) (@vweevers)
  • Upgrade standard devDependency from ^12.0.0 to ^13.0.1 (#341) (@vweevers)

Added

  • Add experimental clear() method to delete all entries or a range (#310) (@vweevers).

6.0.3 - 2019-04-26

Changed

  • Upgrade nyc devDependency from ^13.2.0 to ^14.0.0 (#334) (@vweevers)

Fixed

6.0.2 - 2019-03-30

Changed

Fixed

6.0.1 - 2018-12-27

Changed

  • Upgrade hallmark devDependency from 0.0.2 to 0.1.0 (#316) (@vweevers)
  • Split v6 upgrade guide into sections for consumers and implementors (@vweevers)

Fixed

  • Remove range tests that assumed zero-length strings or Buffers meant "not defined" (#319) (@vweevers)

6.0.0 - 2018-10-20

If you are upgrading: please see UPGRADING.md.

Changed

Added

Removed

Fixed

5.0.0 - 2018-05-22

If you are upgrading: please see UPGRADING.md.

Changed

Added

Removed

4.0.3 - 2018-02-21

Changed

Fixed

  • Remove invalid TypeScript from Batch (@Tapppi)
  • Add JSDoc to incorrectly inferred TypeScript types (@Tapppi)

4.0.2 - 2018-02-09

Fixed

  • Fix iterator#next to return this (@vweevers)

4.0.1 - 2018-02-09

This was released as a patch because it only changed tests and TypeScript typings (which are marked experimental and don't follow semver).

Added

  • Run test suite in TypeScript in addition to Node.js (@vweevers)
  • Add TypeScript smoke test (@vweevers)
  • Add TypeScript readme section with stability badge (@vweevers)

Removed

  • Remove obsolete parameters from tests (@vweevers)

Fixed

  • Update TypeScript typings for v4 (@vweevers)
  • Use ES6 classes in tests to please TypeScript (@vweevers)
  • Define default methods on prototype to please TypeScript (@vweevers)

4.0.0 - 2018-01-20

If you are upgrading: please see UPGRADING.md.

Changed

  • Ignore empty range options in AbstractLevelDOWN#_setupIteratorOptions (@ralphtheninja)
  • Make testCommon.js the default value for testCommon parameter (@ralphtheninja)
  • Use Buffer.isBuffer() instead of AbstractLevelDOWN#isBuffer (@ralphtheninja)
  • Cleanup iterator tests (#161) (@ralphtheninja)
  • Pass test function as a parameter instead of setting local global (@ralphtheninja)
  • Assert batch type is 'put' or 'del' (@vweevers)
  • Assert batch array elements are objects (@vweevers)

Added

Removed

  • Remove isLevelDOWN function and corresponding tests (@ralphtheninja)
  • Remove AbstractLevelDOWN#approximateSize method and corresponding tests (@ralphtheninja)
  • Remove testBuffer in abstract/put-get-del-test.js (@ralphtheninja)
  • Remove object value test in abstract/put-test.js (@vweevers)
  • Remove serialize buffer tests (@vweevers)
  • Remove serialize object tests (@vweevers)
  • Remove BufferType parameter in abstract/put-get-del-test.js, use Buffer (@ralphtheninja)

Fixed

  • Ensure stores are closed properly (fixes problems on Windows) (@ralphtheninja)
  • Call back errors on next tick to avoid zalgo (@vweevers)

3.0.0 - 2017-11-04

If you are upgrading: please see UPGRADING.md.

Added

Removed

  • Drop support for 0.12. Cause for new major version! (@vweevers)

Fixed

2.7.2 - 2017-10-11

Changed

2.7.1 - 2017-09-30

Changed

2.7.0 - 2017-09-12

Added

2.6.3 - 2017-09-05

Changed

  • Upgrade dependencies (@ralphtheninja)
  • Convert nullish values to empty strings (@bigeasy)
  • Use t.equal(a, b) instead of t.ok(a === b) (@bigeasy)
  • Relax tests for serializing object in abstract/chained-batch-test.js (@ralphtheninja)

Added

Fixed

2.6.2 - 2017-07-30

Changed

Added

Fixed

2.6.1 - 2016-09-12

Fixed

  • Fix null case in default value serializer (fixes problems in 2.6.0) (@juliangruber)

2.6.0 - 2016-03-10

This release was a breaking change. See @juliangruber's comment for more information.

Changed

  • Use proto delegation to patch methods on db (@deanlandolt)
  • Allow serialization functions to return buffers (@deanlandolt)

Added

  • Add collectBatchOps function to buffer _put and _del inputs in abstract/chained-batch-test.js (@deanlandolt)

Removed

  • Remove unnecessary initialization hackery in abstract/chained-batch-test.js (@deanlandolt)

2.5.0 - 2016-05-01

Changed

  • Upgrade dependencies and add more node versions to Travis (@ralphtheninja)

Added

Removed

Fixed

2.4.1 - 2015-08-29

Fixed

2.4.0 - 2015-05-19

Added

2.3.1 - 2015-05-18

Added

Removed

  • Extract Contributors section from README into level/community (@ralphtheninja)

Fixed

2.3.0 - 2015-05-18

Changed

Added

2.2.2 - 2015-05-13

Fixed

2.2.1 - 2015-05-12

Fixed

2.2.0 - 2015-05-10

Added

  • Test { sync: true } option in abstract/put-test.js (@juliangruber)

2.1.4 - 2015-04-28

Fixed

2.1.3 - 2015-04-28

Changed

2.1.2 - 2015-04-27

Changed

2.1.1 - 2015-04-27

Changed

Added

Fixed

  • Include .nonErrorValues() test in abstract/put-get-del-test.js (@hden)
  • rvagg/node-abstract-leveldown moved to level/abstract-leveldown (@ralphtheninja)
  • Fix Travis for 0.8 (@ralphtheninja)

2.1.0 - 2014-11-09

Changed

  • Use setTimeout instead of process.nextTick (@bigeasy)

Added

Fixed

  • Don't fail if no value is returned by ._get (@watson)
  • Use error test function when testing for errors (@watson)

2.0.3 - 2014-10-02

No change.

2.0.2 - 2014-10-02

Added

2.0.1 - 2014-09-01

Changed

  • Set default values for options to .open, .get, .put, .del and .batch (@watson)
  • Update pattern for setting default options for the iterator (@watson)
  • Allow boolean options to be falsy/truthy (@watson)

Removed

  • Remove default options that are too LevelDOWN specific (@watson)

2.0.0 - 2014-08-26

Changed

  • Switch to allowing writes of empty values, null, undefined, '', [] and empty buffer (@juliangruber)
  • Rename AbstractLevelDOWN#_checkKeyValue to AbstractLevelDOWN#_checkKey (@rvagg)

1.0.0 - 2014-08-24

Changed

  • Ensure Boolean iterator options are Boolean (@watson)

Added

Removed

  • Remove options.start hackery (@rvagg)

0.12.4 - 2014-08-20

Changed

Added

  • Test that simple-iterator returns buffers (@kesla)
  • Test implicit snapshots (@kesla)

0.12.3 - 2014-06-27

Changed

0.12.2 - 2014-04-26

Changed

  • Have isTypedArray check for existence of ArrayBuffer and Uint8Array constructors before usage (@rvagg)

0.12.1 - 2014-04-26

Changed

  • Set default BufferType in abstract/put-get-del-test.js to Buffer instead of ArrayBuffer (@maxogden)

0.12.0 - 2014-03-12

Changed

  • Revert to pure Buffer and remove usage of Uint16Array (@rvagg)

0.11.4 - 2014-03-11

Removed

  • Remove duplicate call to t.end() (@maxogden)

0.11.3 - 2014-01-26

Changed

  • Loosen the buffer type check (@rvagg)

0.11.2 - 2013-12-05

Added

Fixed

  • Fix iterator tests in test.js (@rvagg)

0.11.1 - 2013-11-15

Changed

  • Adjust abstract/approximate-size-test.js to account for snappy compression (@rvagg)

0.11.0 - 2013-10-14

Added

  • Normalize iterator() options with AbstractLevelDOWN#_setupIteratorOptions (@rvagg)

0.10.2 - 2013-09-06

Changed

  • Refactor duplicated versions of isTypedArray into abstract/util.js (@rvagg)
  • Refactor duplicated versions of 'NotFound' checks into abstract/util.js, fixed too-strict version in get-test.js (@rvagg)

0.10.1 - 2013-08-29

Changed

  • Relax check for Not Found error message to be case insensitive in get-test.js (@rvagg)

Added

0.10.0 - 2013-08-19

Added

0.9.0 - 2013-08-11

Changed

  • Make AbstractChainedBatch extensible (@kesla)
  • Export AbstractChainedBatch from abstract-leveldown.js (@kesla)

Added

  • Test simultaneous get's (@kesla)
  • Test AbstractChainedBatch extensibility (@kesla)

Fixed

  • Fix broken test assertion in abstract/get-test.js (@rvagg)
  • Fix tests that weren't running properly (@kesla)

0.8.2 - 2013-08-02

No changes. Merely published changes made in 0.8.1.

0.8.1 - 2013-08-02

The version in package.json was changed from 0.7.4 to 0.8.1. The 0.8.1 tag exists but this version was never published to npm.

Changed

  • Remove use of const in testCommon.js (@rvagg)

0.8.0 - 2013-08-02

It seems the version in package.json was never changed to 0.8.0 in the git history, even though the 0.8.0 tag exists. Most likely package.json was modified locally during npm publish but was never committed.

Changed

  • Use process.browser check instead of process.title == 'browser' (@rvagg)

Added

  • Add BufferType parameter to abstract/put-get-del-test.js for bops support (@rvagg)
  • Add isTypedArray function which checks ArrayBuffer or Uint8Array for bops support (@rvagg)

Fixed

  • Fix cleanup function not calling back when browserified (@rvagg)

0.7.4 - 2013-08-02

Fixed

  • Fix problems related to browserify and rimraf (@rvagg)

0.7.3 - 2013-07-26

Added

0.7.2 - 2013-07-08

Changed

  • Freeze chained batch state after .write() has been called (@rvagg)
  • Make NotFound error case insensitive (@rvagg)
  • Use self rather than binding functions to this (@juliangruber)

Added

  • Add AbstractChainedBatch#_checkWritten (@rvagg)
  • Test delete on non-existent key (@rvagg)
  • Test iterator with start after database end (@juliangruber)

Fixed

  • Don't coerce values to strings in browser (@maxogden)
  • Make tests work in node and browser (@maxogden)

0.7.1 - 2013-05-15

Changed

  • Adjust tests to be browserable (@rvagg)

0.7.0 - 2013-05-14

Added

  • Add AbstractChainedBatch#clear (@rvagg)

0.6.1 - 2013-05-14

Changed

  • Make AbstractIterator call back with an error instead of throwing on nexting and ending (@mcollina)

0.6.0 - 2013-05-14

Changed

  • Split t.deepEqual() into multiple t.equal() in abstract/iterator-test.js (@rvagg)
  • Make AbstractIterator call back with an error instead of throwing on nexting and ending (@mcollina)

0.5.0 - 2013-05-14

Changed

  • Make iterator.end(cb) and iterator.next(cb) call back with an error instead of throwing (@mcollina)

0.4.0 - 2013-05-14

Changed

  • Move AbstractIterator from abstract-leveldown.js to abstract-iterator.js (@rvagg)

Added

  • Add AbstractChainedBatch (@rvagg)
  • Add AbstractLevelDOWN#_chainedBatch (@rvagg)
  • Add abstract/batch-test.js and abstract/chained-batch-test.js (@rvagg)

0.4.0-1 - 2013-05-14

Added

0.3.0 - 2013-05-04

Changed

  • Use this._checkKeyValue() instead of local function (@rvagg)
  • Use this._isBuffer() instead of Buffer.isBuffer() (@rvagg)

Added

  • Restore test for opening the database without options (@rvagg)
  • Add AbstractLevelDOWN#_isBuffer so it can be overridden (@rvagg)
  • Add AbstractLevelDOWN#_checkKeyValue so it can be overridden (@rvagg)

0.2.3 - 2013-05-04

Removed

  • Remove test for opening the database without options (@rvagg)

0.2.2 - 2013-05-04

Changed

  • Split .open() tests into .open() and .openAdvanced() (@rvagg)

0.2.1 - 2013-05-04

Changed

  • Convert values to string in abstract/put-get-del-test.js if Buffer is undefined (@rvagg)

0.2.0 - 2013-05-04

Changed

  • Convert values to string in abstract/get-test.js if Buffer is undefined (@rvagg)
  • Don't stringify keys and values in abstract/iterator-test.js (@maxogden)

Added

  • Add process.browser check for start and end keys in browser (@maxogden)
  • Add levelup contributors (@rvagg)

Fixed

0.1.0 - 2013-04-23

Added

  • Import abstract tests from leveldown (@maxogden)

Fixed

0.0.2 - 2013-03-18

Changed

  • Export checkKeyValue (@rvagg)

Added

  • Add node 0.10 to Travis (@rvagg)
  • Add Buffer.isBuffer() checks to keys and values (@rvagg)

0.0.1 - 2013-03-18

Added

  • Add checkKeyValue function for more complete error checking (@rvagg)

0.0.0 - 2013-03-15

First release. :seedling: