Skip to content

Commit def791f

Browse files
committed
Remove compatibility checks for levelup & friends (#52)
1 parent d89e68e commit def791f

File tree

8 files changed

+3
-100
lines changed

8 files changed

+3
-100
lines changed

UPGRADING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ _This is a work in progress upgrade guide for the upcoming 2.0.0 release._
4848

4949
The guide for this release consists of two sections. One for the public API, relevant to all consumers of `abstract-level` and implementations thereof (`level`, `classic-level`, `memory-level` et cetera) and another for the private API that only implementors should have to read.
5050

51+
If you're upgrading from `levelup`, `abstract-leveldown` or other old modules, it's recommended to first upgrade to `abstract-level` 1.x because that version includes compatibility checks that have since been removed.
52+
5153
### 1. Public API
5254

5355
#### 1.1. Callbacks have been removed

abstract-iterator.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,6 @@ class IteratorDecodeError extends ModuleError {
405405
// }
406406
// }
407407

408-
// To help migrating to abstract-level
409-
for (const k of ['_ended property', '_nexting property', '_end method']) {
410-
Object.defineProperty(AbstractIterator.prototype, k.split(' ')[0], {
411-
get () { throw new ModuleError(`The ${k} has been removed`, { code: 'LEVEL_LEGACY' }) },
412-
set () { throw new ModuleError(`The ${k} has been removed`, { code: 'LEVEL_LEGACY' }) }
413-
})
414-
}
415-
416408
function assertStatus (iterator) {
417409
if (iterator[kClosing]) {
418410
throw new ModuleError('Iterator is not open: cannot read after close()', {

lib/abstract-sublevel.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ const defaults = { separator: '!' }
2323
module.exports = function ({ AbstractLevel }) {
2424
class AbstractSublevel extends AbstractLevel {
2525
static defaults (options) {
26-
// To help migrating from subleveldown to abstract-level
27-
if (typeof options === 'string') {
28-
throw new ModuleError('The subleveldown string shorthand for { separator } has been removed', {
29-
code: 'LEVEL_LEGACY'
30-
})
31-
} else if (options && options.open) {
32-
throw new ModuleError('The subleveldown open option has been removed', {
33-
code: 'LEVEL_LEGACY'
34-
})
35-
}
36-
3726
if (options == null) {
3827
return defaults
3928
} else if (!options.separator) {

lib/range-options.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const ModuleError = require('module-error')
43
const hasOwnProperty = Object.prototype.hasOwnProperty
54
const rangeOptions = new Set(['lt', 'lte', 'gt', 'gte'])
65

@@ -11,17 +10,6 @@ module.exports = function (options, keyEncoding) {
1110
if (!hasOwnProperty.call(options, k)) continue
1211
if (k === 'keyEncoding' || k === 'valueEncoding') continue
1312

14-
if (k === 'start' || k === 'end') {
15-
throw new ModuleError(`The legacy range option '${k}' has been removed`, {
16-
code: 'LEVEL_LEGACY'
17-
})
18-
} else if (k === 'encoding') {
19-
// To help migrating to abstract-level
20-
throw new ModuleError("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead", {
21-
code: 'LEVEL_LEGACY'
22-
})
23-
}
24-
2513
if (rangeOptions.has(k)) {
2614
// Note that we don't reject nullish and empty options here. While
2715
// those types are invalid as keys, they are valid as range options.

test/clear-test.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,6 @@
33
const isBuffer = require('is-buffer')
44
const { Buffer } = require('buffer')
55

6-
exports.args = function (test, testCommon) {
7-
test('clear() with legacy range options', async function (t) {
8-
t.plan(2)
9-
10-
const db = testCommon.factory()
11-
await db.open()
12-
13-
try {
14-
await db.clear({ start: 'foo' })
15-
} catch (err) {
16-
t.is(err.code, 'LEVEL_LEGACY')
17-
}
18-
19-
try {
20-
await db.clear({ end: 'foo' })
21-
} catch (err) {
22-
t.is(err.code, 'LEVEL_LEGACY')
23-
}
24-
25-
return db.close()
26-
})
27-
}
28-
296
exports.clear = function (test, testCommon) {
307
makeTest('string', ['a', 'b'])
318

@@ -128,7 +105,6 @@ exports.events = function (test, testCommon) {
128105
}
129106

130107
exports.all = function (test, testCommon) {
131-
exports.args(test, testCommon)
132108
exports.events(test, testCommon)
133109
exports.clear(test, testCommon)
134110
}

test/self.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ test('rangeOptions', function (t) {
777777
t.end()
778778
}
779779

780-
t.plan(11)
780+
t.plan(10)
781781
t.test('setup', async (t) => db.open())
782782

783783
t.test('default options', function (t) {
@@ -859,21 +859,6 @@ test('rangeOptions', function (t) {
859859
})
860860
verifyOptions(t, getRangeOptions(options, db.keyEncoding('utf8')))
861861
})
862-
863-
t.test('rejects legacy range and encoding options', function (t) {
864-
t.plan(3)
865-
866-
for (const key of ['start', 'end', 'encoding']) {
867-
const options = {}
868-
options[key] = 'x'
869-
870-
try {
871-
getRangeOptions(options, db.keyEncoding('utf8'))
872-
} catch (err) {
873-
t.is(err.code, 'LEVEL_LEGACY')
874-
}
875-
}
876-
})
877862
})
878863

879864
require('./self/abort-test')

test/self/abstract-iterator-test.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,26 +189,3 @@ for (const Ctor of [AbstractIterator, AbstractKeyIterator, AbstractValueIterator
189189
await db.close()
190190
})
191191
}
192-
193-
test('AbstractIterator throws when accessing legacy properties', async function (t) {
194-
t.plan(3 * 2)
195-
196-
const db = testCommon.factory()
197-
await db.open()
198-
const it = new AbstractIterator(db, {})
199-
200-
for (const k of ['_ended property', '_nexting property', '_end method']) {
201-
try {
202-
// eslint-disable-next-line no-unused-expressions
203-
it[k.split(' ')[0]]
204-
} catch (err) {
205-
t.is(err.code, 'LEVEL_LEGACY')
206-
}
207-
208-
try {
209-
it[k.split(' ')[0]] = 123
210-
} catch (err) {
211-
t.is(err.code, 'LEVEL_LEGACY')
212-
}
213-
}
214-
})

test/self/sublevel-test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,6 @@ test('sublevel prefix and options', function (t) {
161161
t.end()
162162
})
163163

164-
t.test('legacy sublevel(down) options', function (t) {
165-
t.throws(() => new NoopLevel().sublevel('foo', 'bar'), (err) => err.code === 'LEVEL_LEGACY')
166-
t.throws(() => new NoopLevel().sublevel('foo', { open: () => {} }), (err) => err.code === 'LEVEL_LEGACY')
167-
t.end()
168-
})
169-
170164
// See https://github.com/Level/subleveldown/issues/78
171165
t.test('doubly nested sublevel has correct prefix', async function (t) {
172166
t.plan(1)

0 commit comments

Comments
 (0)