Skip to content

Commit

Permalink
stream: forward writableObjectMode
Browse files Browse the repository at this point in the history
Duplex did not properly forward writableObjectMode.

Fixes: #33388

PR-URL: #33390
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
ronag committed May 18, 2020
1 parent 0e5b975 commit 2361b5c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ ObjectDefineProperties(Duplex.prototype, {
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable'),
writableHighWaterMark:
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark'),
writableObjectMode:
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableObjectMode'),
writableBuffer:
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer'),
writableLength:
Expand Down
31 changes: 31 additions & 0 deletions test/parallel/test-stream-duplex-props.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

require('../common');
const assert = require('assert');
const { Duplex } = require('stream');

{
const d = new Duplex({
objectMode: true,
highWaterMark: 100
});

assert.strictEqual(d.writableObjectMode, true);
assert.strictEqual(d.writableHighWaterMark, 100);
assert.strictEqual(d.readableObjectMode, true);
assert.strictEqual(d.readableHighWaterMark, 100);
}

{
const d = new Duplex({
readableObjectMode: false,
readableHighWaterMark: 10,
writableObjectMode: true,
writableHighWaterMark: 100
});

assert.strictEqual(d.writableObjectMode, true);
assert.strictEqual(d.writableHighWaterMark, 100);
assert.strictEqual(d.readableObjectMode, false);
assert.strictEqual(d.readableHighWaterMark, 10);
}

0 comments on commit 2361b5c

Please sign in to comment.