From b996e3b4b58b8d16846f86acb0098826de0e03f5 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 29 Dec 2020 15:20:41 +0100 Subject: [PATCH] stream: do not use _stream_* anymore Remove all leftover usage of _stream_* and keep all of them as legacy. We do not deprecate the old modules to avoid disrupition and ease maintainance. PR-URL: https://github.com/nodejs/node/pull/36684 Reviewed-By: Robert Nagy Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- lib/_stream_duplex.js | 5 ++--- lib/_stream_passthrough.js | 5 ++--- lib/_stream_readable.js | 5 ++--- lib/_stream_transform.js | 5 ++--- lib/_stream_writable.js | 5 ++--- test/parallel/test-stream-aliases-legacy.js | 14 ++++++++++++++ test/parallel/test-stream-pipe-after-end.js | 3 +-- test/parallel/test-stream-pipe-needDrain.js | 3 +-- .../test-stream2-base64-single-char-read-end.js | 3 +-- test/parallel/test-stream2-basic.js | 3 +-- test/parallel/test-stream2-compatibility.js | 3 +-- test/parallel/test-stream2-decode-partial.js | 2 +- test/parallel/test-stream2-objects.js | 3 +-- test/parallel/test-stream2-readable-from-list.js | 2 +- .../test-stream2-readable-non-empty-end.js | 2 +- .../parallel/test-stream2-readable-wrap-destroy.js | 2 +- test/parallel/test-stream2-readable-wrap-empty.js | 2 +- test/parallel/test-stream2-readable-wrap-error.js | 2 +- test/parallel/test-stream2-readable-wrap.js | 3 +-- test/parallel/test-stream2-set-encoding.js | 2 +- test/parallel/test-stream2-transform.js | 3 +-- test/parallel/test-stream2-writable.js | 3 +-- 22 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 test/parallel/test-stream-aliases-legacy.js diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 9e46d02ddcb3d3..c32d589ae196fd 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -1,6 +1,5 @@ 'use strict'; -// TODO(mcollina): deprecate this file +// Keep this file as an alias for the full stream module. -const Duplex = require('internal/streams/duplex'); -module.exports = Duplex; +module.exports = require('stream').Duplex; diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js index dbf8646e009931..f1c775202805ef 100644 --- a/lib/_stream_passthrough.js +++ b/lib/_stream_passthrough.js @@ -1,6 +1,5 @@ 'use strict'; -// TODO(mcollina): deprecate this file +// Keep this file as an alias for the full stream module. -const PassThrough = require('internal/streams/passthrough'); -module.exports = PassThrough; +module.exports = require('stream').PassThrough; diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index c31dde30645726..4729e7fde3e393 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -1,6 +1,5 @@ 'use strict'; -// TODO(mcollina): deprecate this file +// Keep this file as an alias for the full stream module. -const Readable = require('internal/streams/readable'); -module.exports = Readable; +module.exports = require('stream').Readable; diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 50150638d9db8c..4901f296692d11 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -1,6 +1,5 @@ 'use strict'; -// TODO(mcollina): deprecate this file +// Keep this file as an alias for the full stream module. -const Transform = require('internal/streams/transform'); -module.exports = Transform; +module.exports = require('stream').Transform; diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index e328a9434c85a9..d6f1974422d3f3 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -1,6 +1,5 @@ 'use strict'; -// TODO(mcollina): deprecate this file +// Keep this file as an alias for the full stream module. -const Writable = require('internal/streams/writable'); -module.exports = Writable; +module.exports = require('stream').Writable; diff --git a/test/parallel/test-stream-aliases-legacy.js b/test/parallel/test-stream-aliases-legacy.js new file mode 100644 index 00000000000000..2c87f0ad0fa4a4 --- /dev/null +++ b/test/parallel/test-stream-aliases-legacy.js @@ -0,0 +1,14 @@ +'use strict'; + +require('../common'); + +const assert = require('assert'); +const stream = require('stream'); + +// Verify that all individual aliases are left in place. + +assert.strictEqual(stream.Readable, require('_stream_readable')); +assert.strictEqual(stream.Writable, require('_stream_writable')); +assert.strictEqual(stream.Duplex, require('_stream_duplex')); +assert.strictEqual(stream.Transform, require('_stream_transform')); +assert.strictEqual(stream.PassThrough, require('_stream_passthrough')); diff --git a/test/parallel/test-stream-pipe-after-end.js b/test/parallel/test-stream-pipe-after-end.js index 2eb714b2ca7d3e..045d27e0855374 100644 --- a/test/parallel/test-stream-pipe-after-end.js +++ b/test/parallel/test-stream-pipe-after-end.js @@ -22,8 +22,7 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const Readable = require('_stream_readable'); -const Writable = require('_stream_writable'); +const { Readable, Writable } = require('stream'); class TestReadable extends Readable { constructor(opt) { diff --git a/test/parallel/test-stream-pipe-needDrain.js b/test/parallel/test-stream-pipe-needDrain.js index 0836c81da22438..7faf45417a5f4a 100644 --- a/test/parallel/test-stream-pipe-needDrain.js +++ b/test/parallel/test-stream-pipe-needDrain.js @@ -2,8 +2,7 @@ const common = require('../common'); const assert = require('assert'); -const Readable = require('_stream_readable'); -const Writable = require('_stream_writable'); +const { Readable, Writable } = require('stream'); // Pipe should pause temporarily if writable needs drain. { diff --git a/test/parallel/test-stream2-base64-single-char-read-end.js b/test/parallel/test-stream2-base64-single-char-read-end.js index 10259e280454c0..2e1eb15f9fd010 100644 --- a/test/parallel/test-stream2-base64-single-char-read-end.js +++ b/test/parallel/test-stream2-base64-single-char-read-end.js @@ -21,8 +21,7 @@ 'use strict'; require('../common'); -const R = require('_stream_readable'); -const W = require('_stream_writable'); +const { Readable: R, Writable: W } = require('stream'); const assert = require('assert'); const src = new R({ encoding: 'base64' }); diff --git a/test/parallel/test-stream2-basic.js b/test/parallel/test-stream2-basic.js index 7121f7bda75b02..862e45417626c8 100644 --- a/test/parallel/test-stream2-basic.js +++ b/test/parallel/test-stream2-basic.js @@ -22,8 +22,7 @@ 'use strict'; const common = require('../common'); -const R = require('_stream_readable'); -const W = require('_stream_writable'); +const { Readable: R, Writable: W } = require('stream'); const assert = require('assert'); const EE = require('events').EventEmitter; diff --git a/test/parallel/test-stream2-compatibility.js b/test/parallel/test-stream2-compatibility.js index bd0314ec1a9918..d760db8b32271c 100644 --- a/test/parallel/test-stream2-compatibility.js +++ b/test/parallel/test-stream2-compatibility.js @@ -21,8 +21,7 @@ 'use strict'; require('../common'); -const R = require('_stream_readable'); -const W = require('_stream_writable'); +const { Readable: R, Writable: W } = require('stream'); const assert = require('assert'); let ondataCalled = 0; diff --git a/test/parallel/test-stream2-decode-partial.js b/test/parallel/test-stream2-decode-partial.js index 9b1baf7fd677f4..9d9ae21bfec7ae 100644 --- a/test/parallel/test-stream2-decode-partial.js +++ b/test/parallel/test-stream2-decode-partial.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -const Readable = require('_stream_readable'); +const { Readable } = require('stream'); const assert = require('assert'); let buf = ''; diff --git a/test/parallel/test-stream2-objects.js b/test/parallel/test-stream2-objects.js index f58ea4a32a1e7d..a6723daca6c761 100644 --- a/test/parallel/test-stream2-objects.js +++ b/test/parallel/test-stream2-objects.js @@ -22,8 +22,7 @@ 'use strict'; const common = require('../common'); -const Readable = require('_stream_readable'); -const Writable = require('_stream_writable'); +const { Readable, Writable } = require('stream'); const assert = require('assert'); function toArray(callback) { diff --git a/test/parallel/test-stream2-readable-from-list.js b/test/parallel/test-stream2-readable-from-list.js index 6564a01691f09e..d5d113304e4925 100644 --- a/test/parallel/test-stream2-readable-from-list.js +++ b/test/parallel/test-stream2-readable-from-list.js @@ -23,7 +23,7 @@ 'use strict'; require('../common'); const assert = require('assert'); -const fromList = require('_stream_readable')._fromList; +const fromList = require('stream').Readable._fromList; const BufferList = require('internal/streams/buffer_list'); const util = require('util'); diff --git a/test/parallel/test-stream2-readable-non-empty-end.js b/test/parallel/test-stream2-readable-non-empty-end.js index ba289fb91275e3..417f2c3b0e92e3 100644 --- a/test/parallel/test-stream2-readable-non-empty-end.js +++ b/test/parallel/test-stream2-readable-non-empty-end.js @@ -22,7 +22,7 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const Readable = require('_stream_readable'); +const { Readable } = require('stream'); let len = 0; const chunks = new Array(10); diff --git a/test/parallel/test-stream2-readable-wrap-destroy.js b/test/parallel/test-stream2-readable-wrap-destroy.js index b0f4714c741202..e310ae09e6ff53 100644 --- a/test/parallel/test-stream2-readable-wrap-destroy.js +++ b/test/parallel/test-stream2-readable-wrap-destroy.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -const Readable = require('_stream_readable'); +const { Readable } = require('stream'); const EE = require('events').EventEmitter; const oldStream = new EE(); diff --git a/test/parallel/test-stream2-readable-wrap-empty.js b/test/parallel/test-stream2-readable-wrap-empty.js index 1489717f3e49c3..3dbbdaa9b5afbf 100644 --- a/test/parallel/test-stream2-readable-wrap-empty.js +++ b/test/parallel/test-stream2-readable-wrap-empty.js @@ -22,7 +22,7 @@ 'use strict'; const common = require('../common'); -const Readable = require('_stream_readable'); +const { Readable } = require('stream'); const EE = require('events').EventEmitter; const oldStream = new EE(); diff --git a/test/parallel/test-stream2-readable-wrap-error.js b/test/parallel/test-stream2-readable-wrap-error.js index a05ae8179b06ef..2d2c26e2cadc46 100644 --- a/test/parallel/test-stream2-readable-wrap-error.js +++ b/test/parallel/test-stream2-readable-wrap-error.js @@ -2,7 +2,7 @@ const common = require('../common'); const assert = require('assert'); -const Readable = require('_stream_readable'); +const { Readable } = require('stream'); const EE = require('events').EventEmitter; class LegacyStream extends EE { diff --git a/test/parallel/test-stream2-readable-wrap.js b/test/parallel/test-stream2-readable-wrap.js index 69f055fd7e535e..eebe72bc0dd8ad 100644 --- a/test/parallel/test-stream2-readable-wrap.js +++ b/test/parallel/test-stream2-readable-wrap.js @@ -22,8 +22,7 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const Readable = require('_stream_readable'); -const Writable = require('_stream_writable'); +const { Readable, Writable } = require('stream'); const EE = require('events').EventEmitter; function runTest(highWaterMark, objectMode, produce) { diff --git a/test/parallel/test-stream2-set-encoding.js b/test/parallel/test-stream2-set-encoding.js index 0095fa544db114..2d35b161bf0143 100644 --- a/test/parallel/test-stream2-set-encoding.js +++ b/test/parallel/test-stream2-set-encoding.js @@ -22,7 +22,7 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const R = require('_stream_readable'); +const { Readable: R } = require('stream'); class TestReader extends R { constructor(n, opts) { diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js index ad9e1a2237bd72..fe27c1c1b6ddcf 100644 --- a/test/parallel/test-stream2-transform.js +++ b/test/parallel/test-stream2-transform.js @@ -22,8 +22,7 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); -const PassThrough = require('_stream_passthrough'); -const Transform = require('_stream_transform'); +const { PassThrough, Transform } = require('stream'); { // Verify writable side consumption diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index 03835bb1bd0465..3d16fb62df3313 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -22,8 +22,7 @@ 'use strict'; const common = require('../common'); -const W = require('_stream_writable'); -const D = require('_stream_duplex'); +const { Writable: W, Duplex: D } = require('stream'); const assert = require('assert'); class TestWriter extends W {