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 authored and targos committed Jun 2, 2020
1 parent f24292e commit 1db0d51
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 1db0d51

Please sign in to comment.