This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the CHANGELOG
.
This release upgrades to abstract-level
2.0.0 which adds hooks and drops callbacks, not-found errors and support of Node.js < 16. Please refer to the upgrade guide of abstract-level
. The only thing to add is that memory-level
also drops Node.js 16.
Introducing memory-level
: a fork of memdown
that removes the need for level-mem
, levelup
and more. It implements the abstract-level
interface instead of abstract-leveldown
and thus has the same API as level-mem
and levelup
including encodings, promises and events. In addition, you can now choose to use Uint8Array instead of Buffer. Sublevels are builtin.
We've put together several upgrade guides for different modules. See the FAQ to find the best upgrade guide for you. This upgrade guide describes how to replace memdown
or level-mem
with memory-level
. If you are using any of the following, please also read the upgrade guide of abstract-level@1
which goes into more detail about these:
- Specific error messages (replaced with error codes)
- The callback argument of the constructor (gone)
- The
'binary'
encoding (renamed to'buffer'
, with'binary'
as an alias) - The
db.iterator().end()
method (renamed toclose()
, withend()
as an alias) - Zero-length keys and range options (now valid)
- The
'ascii'
,'ucs2'
,'utf16le'
and'id'
encodings (gone) - The undocumented
encoding
alias for thevalueEncoding
option (gone) - The
db.supports.bufferKeys
property.
Support of Node.js 10 has been dropped.
Using new
is now required. If you previously did:
const mem = require('level-mem')
const db1 = mem()
const db2 = mem({ valueEncoding: 'json' })
You must now do:
const { MemoryLevel } = require('memory-level')
const db1 = new MemoryLevel()
const db2 = new MemoryLevel({ valueEncoding: 'json' })
Node.js readable streams must now be created with a new standalone module called level-read-stream
, rather than database methods like db.createReadStream()
. Please see its upgrade guide for details.
This section is only relevant if you're using memdown
directly, rather than as a transitive dependency of level-mem
.
The asBuffer
, valueAsBuffer
and keyAsBuffer
options have been replaced with encoding options. The default encoding is 'utf8'
which means operations return strings rather than Buffers by default. If you previously did:
const memdown = require('memdown')
const db = memdown()
db.get('example', { asBuffer: false }, callback)
db.get('example', callback)
You must now do:
const { MemoryLevel } = require('memory-level')
const db = new MemoryLevel()
db.get('example', callback)
db.get('example', { valueEncoding: 'buffer' }, callback)
Or using promises (new):
const str = await db.get('example')
const buf = await db.get('example', { valueEncoding: 'buffer' })
Or using Uint8Array (new):
const arr = await db.get('example', { valueEncoding: 'view' })
If you were wrapping memdown
with levelup
, encoding-down
and / or subleveldown
, remove those modules. If you previously did:
const memdown = require('memdown')
const levelup = require('levelup')
const enc = require('encoding-down')
const subleveldown = require('subleveldown')
const db = levelup(enc(memdown()))
const sublevel = subleveldown(db, 'foo')
You must now do:
const { MemoryLevel } = require('memory-level')
const db = new MemoryLevel()
const sublevel = db.sublevel('foo')
Lastly, private properties like _store
(unlikely used externally) are no longer accessible.
For earlier releases, before memory-level
was forked from memdown
(v6.1.1), please see the upgrade guide of memdown
.