Skip to content

Commit d29bcef

Browse files
committed
Breaking: drop support of abstract-level 1
Follow-up for #18. Category: removal
1 parent e3614fb commit d29bcef

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

UPGRADING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
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](CHANGELOG.md).
44

5+
## 2.0.0
6+
7+
Drops support of `abstract-level` 1 (and its callback API) as well as Node.js < 18. Stick with `level-read-stream` 1 if you need to support both `abstract-level` 1 and 2.
8+
59
## 1.0.0
610

711
If you are migrating from `levelup` or `level <= 7` to an [`abstract-level`](https://github.com/Level/abstract-level) database, that database will no longer have stream methods. If you previously did:

index.js

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const { Readable } = require('readable-stream')
44

55
const kIterator = Symbol('iterator')
6-
const kPromises = Symbol('promises')
76
const kNextv = Symbol('nextv')
87
const kNextvLegacy = Symbol('nextvLegacy')
98
const kDestroy = Symbol('destroy')
@@ -22,11 +21,6 @@ class LevelReadStream extends Readable {
2221
this[kNextv] = this[kNextv].bind(this)
2322
this[kNextvLegacy] = this[kNextvLegacy].bind(this)
2423
this[kDestroy] = this.destroy.bind(this)
25-
26-
// Detect abstract-level 2 by the presence of hooks. Version 2 doesn't
27-
// support callbacks anymore. Version 1 does also support promises but
28-
// that would be slower because it works by wrapping the callback API.
29-
this[kPromises] = db.hooks !== undefined
3024
}
3125

3226
get db () {
@@ -36,14 +30,10 @@ class LevelReadStream extends Readable {
3630
_read (size) {
3731
if (this.destroyed) return
3832

39-
if (this[kPromises]) {
40-
this[kIterator].nextv(size).then(
41-
this[kNextv],
42-
this[kDestroy]
43-
)
44-
} else {
45-
this[kIterator].nextv(size, this[kNextvLegacy])
46-
}
33+
this[kIterator].nextv(size).then(
34+
this[kNextv],
35+
this[kDestroy]
36+
)
4737
}
4838

4939
[kNextvLegacy] (err, items) {
@@ -72,16 +62,10 @@ class LevelReadStream extends Readable {
7262
}
7363

7464
_destroy (err, callback) {
75-
if (this[kPromises]) {
76-
this[kIterator].close().then(
77-
err ? () => callback(err) : callback,
78-
callback
79-
)
80-
} else {
81-
this[kIterator].close(function (err2) {
82-
callback(err || err2)
83-
})
84-
}
65+
this[kIterator].close().then(
66+
err ? () => callback(err) : callback,
67+
callback
68+
)
8569
}
8670
}
8771

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"readable-stream": "^4.6.0"
2323
},
2424
"peerDependencies": {
25-
"abstract-level": ">=1.0.0"
25+
"abstract-level": ">=2.0.0"
2626
},
2727
"peerDependenciesMeta": {
2828
"abstract-level": {

0 commit comments

Comments
 (0)