stream: lazy load end-of-stream

PR-URL: https://github.com/nodejs/node/pull/20567
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
Ruben Bridgewater 2018-05-07 05:12:32 +02:00
parent 5dad1e45e9
commit bf46c371eb
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -3,7 +3,7 @@
'use strict';
const eos = require('internal/streams/end-of-stream');
let eos;
const {
ERR_MISSING_ARGS,
@ -33,6 +33,7 @@ function destroyer(stream, reading, writing, callback) {
closed = true;
});
if (eos === undefined) eos = require('internal/streams/end-of-stream');
eos(stream, { readable: reading, writable: writing }, (err) => {
if (err) return callback(err);
closed = true;