Skip to content

Commit

Permalink
[v12.x backport] stream: remove ambiguous code
Browse files Browse the repository at this point in the history
PR-URL: nodejs#29664
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
ronag authored and Stewart Addison committed Jan 24, 2020
1 parent 3203feb commit 8ff774e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,28 @@ function eos(stream, opts, callback) {

callback = once(callback);

let readable = opts.readable || (opts.readable !== false && stream.readable);
let writable = opts.writable || (opts.writable !== false && stream.writable);
const readable = opts.readable ||
(opts.readable !== false && stream.readable);
const writable = opts.writable ||
(opts.writable !== false && stream.writable);

const onlegacyfinish = () => {
if (!stream.writable) onfinish();
};

let writableEnded = stream._writableState && stream._writableState.finished;
const onfinish = () => {
writable = false;
writableEnded = true;
if (!readable) callback.call(stream);
writableFinished = true;
if (!readable || readableEnded) callback.call(stream);
};

let readableEnded = stream.readableEnded ||
(stream._readableState && stream._readableState.endEmitted);
const onend = () => {
readable = false;
readableEnded = true;
if (!writable) callback.call(stream);
if (!writable || writableFinished) callback.call(stream);
};

const onerror = (err) => {
Expand Down

0 comments on commit 8ff774e

Please sign in to comment.