From 1db0d51ab2ef90e23e64f77486a0f4d6e15e2c5b Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 13 May 2020 21:14:30 +0200 Subject: [PATCH] stream: forward writableObjectMode Duplex did not properly forward writableObjectMode. Fixes: https://github.com/nodejs/node/issues/33388 PR-URL: https://github.com/nodejs/node/pull/33390 Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- lib/_stream_duplex.js | 2 ++ test/parallel/test-stream-duplex-props.js | 31 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/parallel/test-stream-duplex-props.js diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index ced361c8d60898..2b92959a2c3d6c 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -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: diff --git a/test/parallel/test-stream-duplex-props.js b/test/parallel/test-stream-duplex-props.js new file mode 100644 index 00000000000000..aa6b23125a9d9d --- /dev/null +++ b/test/parallel/test-stream-duplex-props.js @@ -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); +}