Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stream: move legacy to lib/internal dir
  • Loading branch information
yorkie committed Jan 7, 2017
commit 876c3adafa1965dd2781334b1060ca6bb28191bd
3 changes: 2 additions & 1 deletion lib/_stream_legacy.js → lib/internal/streams/legacy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const EE = require('events');

module.exports = function(Stream) {
// old-style streams. Note that the pipe method (the only relevant
// part of this class) is overridden in the Readable class.
Expand Down Expand Up @@ -80,7 +82,6 @@ module.exports = function(Stream) {
source.on('close', cleanup);

dest.on('close', cleanup);

dest.emit('pipe', source);

// Allow for unix-like usage: A.pipe(B).pipe(C)
Expand Down
9 changes: 5 additions & 4 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function Stream() {
util.inherits(Stream, EE);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we put this into the internal/* file so that the code is more exactly like what we're removing, instead of wrapping it?


// wrap the old-style stream
require('_stream_legacy')(Stream);
require('internal/streams/legacy')(Stream);
Copy link
Copy Markdown
Member

@mcollina mcollina Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not clear to me. Basically the definition of Stream is divided into two files, whicn is not easy to understand in my opinion. If we also move the definition of Stream, I think internal/streams/stream should also include the 'legacy' bits.

How about we move all _stream prefixed files into internal/streams? That might be a better solution overall.
cc @nodejs/streams.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You couldn't just move those files because that would break someone trying to require() them? Unless you mean leave behind similarly-named files that simple re-export?

Also, I think the point of this PR was to separate the actual old Stream implementation from the other things, like the re-exporting of the various stream types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then why split the definition of it in one file, and the legacy part in another?
Either we just move the legacy bits, we move the full definition, or we move all the streams parts.

I'm 👎 in having both internal/streams/stream and internal/streams/legacy, if we are not moving along readable, writable, etc.


// Note: export Stream before Readable/Writable/Duplex/...
// to avoid a cross-reference(require) issues
module.exports = Stream;

Stream.Readable = require('_stream_readable');
Stream.Writable = require('_stream_writable');
Expand All @@ -19,6 +23,3 @@ Stream.PassThrough = require('_stream_passthrough');

// Backwards-compat with node 0.4.x
Stream.Stream = Stream;

// export
module.exports = Stream;
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
'lib/_stream_transform.js',
'lib/_stream_passthrough.js',
'lib/_stream_wrap.js',
'lib/_stream_legacy.js',
'lib/string_decoder.js',
'lib/sys.js',
'lib/timers.js',
Expand Down Expand Up @@ -97,6 +96,7 @@
'lib/internal/v8_prof_processor.js',
'lib/internal/streams/lazy_transform.js',
'lib/internal/streams/BufferList.js',
'lib/internal/streams/legacy.js',
'deps/v8/tools/splaytree.js',
'deps/v8/tools/codemap.js',
'deps/v8/tools/consarray.js',
Expand Down