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

from Node stream #223

Open
JamesRamm opened this issue Jan 5, 2022 · 2 comments
Open

from Node stream #223

JamesRamm opened this issue Jan 5, 2022 · 2 comments

Comments

@JamesRamm
Copy link

Hi
I am looking at making a little utility for creating a stream from a nodeJS readable stream , this will bring all the nice monadic interfaces of flyd (using map, chain etc is much simpler and clearer than writing transform streams...).

I am thinking of something like this:

function fromReadable(readable) {
  const s = flyd.stream();
  readable.on('data', s);
  readable.on('end',  () => s.end(true));
}

Do you forsee any issues with this? Have I lost backpressure?
Any ideas on how to handle errors?

@StreetStrider
Copy link
Contributor

Have I lost backpressure?

Most likely. flyd is push. Readable is pull. Implementing backpressure in push world requires some careful actions. You need to pass signals back by the pipe which is against push idea.

If you want something nice and simple like flyd but for data consuming, I think your first stop would be callbags. I think they have backpressure implemented as a specific operator and you can implement your own, bc callbag has API to signal back.

The bigger alternatives are most.js and Highland (both not being actively developed).

@nordfjord
Copy link
Collaborator

I'll add IxJS to the list of alternatives when dealing with async iterables

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

3 participants