-
Notifications
You must be signed in to change notification settings - Fork 20
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
Remove the last parameter to Stream #4
Conversation
It should be possible to read and write both String and Buffer at any time; the Node API offers Strings for convenience only, so there is no need for the last type parameter of Stream.
Useful in the case where `setEncoding` has been called, although this is a bad idea in most cases.
I'm happy with this now. It's sort of halfway between the two options I suggested earlier. There's a new |
@@ -0,0 +1,11 @@ | |||
-- | The standard IO streams for the current process. | |||
module Node.Stream.StdIO where |
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.
Does it make sense to put this in a node-process
library like we have HTTP streams in node-http
?
I'm wondering if process objects can be obtained in other ways than just require('process')
.
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.
Quite possibly, yes. I was thinking that library (once it exists) could re-export these.
I'm fairly sure that the only way of getting a process object is the global process
variable (not require('process')
). The only other similar thing I can think of is a child process, but they are different; for instance, a child process' stdin
, stdout
, or stderr
property might be null.
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.
Actually, on second thoughts, yes, I think a node-process
library is a better fit for these. Shall I remove these, and then I can create that library once this is PR merged and released?
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.
I think that makes sense. Once the API is nailed down, things like gzip and crypto streams would probably make nice libraries too.
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.
👍 Ok, done. Agree re gzip and crypto. I think they would be pretty straightforward to wrap too, which is nice.
Looks great! Thanks very much for this. |
I like the new approach to encodings as well. I think this should work fine for I've been wondering lately if it makes sense to just create a monolithic |
:) I don't feel particularly strongly either way about a monolithic repo. The only drawback I can think of is losing the granularity - you might have to upgrade all your code that deals with the filesystem just because you needed a bug fix in the http module, or something. I agree that it is a bit annoying at the moment, having to change a bunch of different libraries because of changes like this, but I also think these sorts of changes will quickly become less frequent. |
|
||
foreign import gzip :: forall eff. Eff (gzip :: GZIP | eff) (Duplex (gzip :: GZIP | eff)) | ||
|
||
foreign import |
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.
Typo?
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.
oops, not sure what happened there.
Ok, I think we're there now |
Remove the last parameter to Stream
Not ready for merging. I'm not yet sure that this is the right approach, see #3.
I guess we should be asking: how likely is it that a PureScript user will want to get readable streams from JavaScript where the encoding is already set, and do stuff with them in PureScript? As opposed to getting them directly in PureScript. For example, I think we can safely assume that PureScript bindings to
http
orfs.createReadStream
won't set an encoding. And: is it acceptable to say that, in the case where a readable stream with an encoding somehow finds its way into a PureScript program, people will need to use some other API?If we do stick with the approach that these commits currently use, which is deciding that this API only works with readable streams without an encoding set, we should remove
setEncoding
and related tests. I haven't gotten around to that just yet.