-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs,stream: introduce FileSystemStream #36408
Conversation
Adds a Trait to group functionality of fs.ReadStream and fs.WriteStream.
ping @ronag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing wrong with it per se but it looks to me like unnecessary abstraction...
Me too, my first impression was that it was useless bloat, but now when I see it fully implemented, I must admit that it is a PR that deletes more lines than it introduces - even if most of the difference comes from removing a few large comment blocks |
// stream.closed = true; | ||
cb(err); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to live on the prototype. Just make it a function taking stream as first param.
cb(er || err); | ||
}); | ||
stream.fd = null; | ||
function FileSystemStream(path, options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be a constructor function. Can be just a regular function taking stream as first param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's taking the options
to, well construct the (Read|Write)Stream
instance (defining properties on it)…
I tend to agree with Robert regarding this sort of abstraction not making the code easier - I didn't want to say that before to not influence bias but I am -0 on this (won't block but generally not in favour). |
I don't feel strongly about this myself, I just find the |
Adds a Trait (abstract class?) to group functionality of
fs.ReadStream
andfs.WriteStream
.Refs: #35922 (comment)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes/cc @mmomtchev