mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

stream.Duplex and net.Socket slightly differs in behavior. Especially when it comes to the case where one side never becomes readable or writable. This aligns Duplex with the behavior of Socket. PR-URL: https://github.com/nodejs/node/pull/32139 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
42 lines
948 B
JavaScript
42 lines
948 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const Duplex = require('stream').Duplex;
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {}
|
|
});
|
|
assert.strictEqual(stream.allowHalfOpen, true);
|
|
stream.on('finish', common.mustNotCall());
|
|
assert.strictEqual(stream.listenerCount('end'), 0);
|
|
stream.resume();
|
|
stream.push(null);
|
|
}
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {},
|
|
allowHalfOpen: false
|
|
});
|
|
assert.strictEqual(stream.allowHalfOpen, false);
|
|
stream.on('finish', common.mustCall());
|
|
assert.strictEqual(stream.listenerCount('end'), 0);
|
|
stream.resume();
|
|
stream.push(null);
|
|
}
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {},
|
|
allowHalfOpen: false
|
|
});
|
|
assert.strictEqual(stream.allowHalfOpen, false);
|
|
stream._writableState.ended = true;
|
|
stream.on('finish', common.mustNotCall());
|
|
assert.strictEqual(stream.listenerCount('end'), 0);
|
|
stream.resume();
|
|
stream.push(null);
|
|
}
|