Skip to content

Commit

Permalink
Breaking: bump readable-stream from 3 to 4
Browse files Browse the repository at this point in the history
See https://github.com/nodejs/readable-stream. TLDR (because you
won't find a changelog): it fast-forwards to Node.js 18 streams and,
apart from all the changes between Node.js 10 and 18, drops support
of Internet Explorer.
  • Loading branch information
vweevers committed Jul 1, 2022
1 parent dafafb2 commit 082b8d6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ws.end()

### `ws = new WriteStream(db[, options])`

Create a [writable stream](https://nodejs.org/dist/latest-v8.x/docs/api/stream.html#stream_class_stream_writable) that operates in object mode, accepting batch operations to be committed with `db.batch()` on each tick of the Node.js event loop. The optional `options` argument may contain:
Create a [writable stream](https://nodejs.org/dist/latest-v18.x/docs/api/stream.html#stream_class_stream_writable) that operates in object mode, accepting batch operations to be committed with `db.batch()` on each tick of the Node.js event loop. The optional `options` argument may contain:

- `type` (string, default: `'put'`): default batch operation type if not set on indididual operations.
- `maxBufferLength` (number, default `Infinity`): limit the size of batches. When exceeded, the stream will stop processing writes until the current batch has been committed.
Expand Down
8 changes: 3 additions & 5 deletions level-ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class WriteStream extends Writable {

super({
objectMode: true,
highWaterMark: options.highWaterMark || 16
highWaterMark: options.highWaterMark || 16,
autoDestroy: true,
emitClose: true
})

this._options = options
Expand All @@ -17,10 +19,6 @@ class WriteStream extends Writable {
this._flushing = false
this._maxBufferLength = options.maxBufferLength || Infinity
this._flush = this._flush.bind(this)

this.on('finish', () => {
this.emit('close')
})
}

_write (data, enc, next) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"UPGRADING.md"
],
"dependencies": {
"readable-stream": "^3.1.0"
"readable-stream": "^4.0.0"
},
"devDependencies": {
"hallmark": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test('race condition between two flushes', function (t, ctx, done) {
const order = monitor(ws)

ws.on('close', function () {
t.same(order, ['batch', 'batch', 'close'])
t.same(order, ['batch', 'batch', 'finish', 'close'])

ctx.verify(ws, done, [
{ key: 'a', value: 'a' },
Expand Down

0 comments on commit 082b8d6

Please sign in to comment.