Skip to content

Commit

Permalink
Remove level-mem compatibility checks
Browse files Browse the repository at this point in the history
Category: removal
  • Loading branch information
vweevers committed Oct 21, 2024
1 parent 58d4f8f commit 03b370d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
10 changes: 1 addition & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,12 @@ for (const Ctor of [MemoryIterator, MemoryKeyIterator, MemoryValueIterator]) {
}

class MemoryLevel extends AbstractLevel {
constructor (location, options, _) {
constructor (location, options) {
// Take a dummy location argument to align with other implementations
if (typeof location === 'object' && location !== null) {
options = location
}

// To help migrating from level-mem to abstract-level
// TODO (v2): remove
if (typeof location === 'function' || typeof options === 'function' || typeof _ === 'function') {
throw new ModuleError('The levelup-style callback argument has been removed', {
code: 'LEVEL_LEGACY'
})
}

let { storeEncoding, ...forward } = options || {}
storeEncoding = storeEncoding || 'buffer'

Expand Down
7 changes: 0 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,3 @@ test('throws on unsupported storeEncoding', function (t) {
t.throws(() => new MemoryLevel({ storeEncoding: 'foo' }), (err) => err.code === 'LEVEL_ENCODING_NOT_SUPPORTED')
t.end()
})

test('throws on legacy level-mem options', function (t) {
t.throws(() => new MemoryLevel(() => {}), (err) => err.code === 'LEVEL_LEGACY')
t.throws(() => new MemoryLevel('x', () => {}), (err) => err.code === 'LEVEL_LEGACY')
t.throws(() => new MemoryLevel('x', {}, () => {}), (err) => err.code === 'LEVEL_LEGACY')
t.end()
})

0 comments on commit 03b370d

Please sign in to comment.