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

flatMap? #73

Closed
wilsonjackson opened this Issue Oct 27, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@wilsonjackson

wilsonjackson commented Oct 27, 2014

It seems like this module could use a flatMap implementation. I've even looked for it in other modules, and can't seem to find a flatMap for node streams (which seems crazy!), only libraries like bacon.js and highland which use their own stream types.

Would you entertain a PR adding flatMap?

@devinus

This comment has been minimized.

devinus commented Jul 31, 2015

I actually need this right now. Unsure how to continue...

@devinus

This comment has been minimized.

devinus commented Jul 31, 2015

For people finding this in the future, I accomplished a "flatMap" by using this:

        .pipe(es.through(function(data) {
          var stream = this;
          data.forEach(function(r) {
            stream.emit('data', r);
          });
        }))
@dominictarr

This comment has been minimized.

Owner

dominictarr commented Jul 31, 2015

@devinus it would be better to do steam.queue(data) instead of stream.emit('data', data)` because then back pause will work correctly.

@devinus

This comment has been minimized.

devinus commented Jul 31, 2015

@dominictarr Interesting. Would you accept a flatMap patch using this functionality?

@devinus

This comment has been minimized.

devinus commented Jul 31, 2015

I wonder why mapSync uses emit rather than queue.

@dominictarr

This comment has been minimized.

Owner

dominictarr commented Jul 31, 2015

@devinus ah, it's probably just old. I don't use this module anymore, i now use https://github.com/dominictarr/pull-stream

If you publish a flatMap module and then make a pr to include it, i'll merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment