Skip to content
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

Stream Promises API? #44

Closed
jamesdbrock opened this issue May 22, 2022 · 5 comments
Closed

Stream Promises API? #44

jamesdbrock opened this issue May 22, 2022 · 5 comments

Comments

@jamesdbrock
Copy link
Member

Starting in Node.js v15, there is a “Stream Promises API”. Do we want to support that in this package?

Would we use the Promise type from aff-promise or web-promise?

From web-promise, I assume. But then we would probably want to settle this issue to make the Stream Promises API useful: nwolverson/purescript-aff-promise#24

@MonoidMusician
Copy link

Can the functionality be made in aff without going through promises, just using the callback api this library already provides?

@jamesdbrock
Copy link
Member Author

Can the functionality be made in aff without going through promises, just using the callback api this library already provides?

Yes, I'm working on that now... https://github.com/jamesdbrock/purescript-node-streams-aff

@jamesdbrock
Copy link
Member Author

jamesdbrock commented May 24, 2022

Node.js seems to have three stream APIs. https://nodejs.org/api/stream.html

  1. The “flowing” API based on event listener callbacks
  2. The “paused” API based on asynchronous completion callbacks
  3. The Promise API

These three APIs were added in chronological order. When API 1 proved to not work, they added API 2, right on top of it in the same namespace. API 1 and 2 are mutually incompatible, and users are admonished to “choose one API style.”

API 2 has proven to not work. It doesn’t work in a specific case which I need: a program which writes to stdout and then exits.

nodejs/node#6456
nodejs/node#6379
https://nodejs.org/api/process.html#a-note-on-process-io

Now there is API 3, the Promise API, which was added right on top of the other APIs in the same namespace but is incompatible with the first two APIs.

There are hints on the internet that API 3 might actually be able to write to stdout and then exit. sparksuite/waterfall-cli#258

So I think I want a PureScript wrapper for the Streams Promises API https://nodejs.org/api/stream.html#streams-promises-api

@jamesdbrock
Copy link
Member Author

I take it back, I think the Stream Promises API is also rubbish and cannot write to stdout and then exit.

@jamesdbrock
Copy link
Member Author

I published https://pursuit.purescript.org/packages/purescript-node-streams-aff which I think solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants