This repository has been archived by the owner. It is now read-only.

flatMap? #73

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

Comments

Projects
None yet
3 participants
@wilsonjackson
Copy link

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.

Copy link

devinus commented Jul 31, 2015

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

@devinus

This comment has been minimized.

Copy link

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.

Copy link
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.

Copy link

devinus commented Jul 31, 2015

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

@devinus

This comment has been minimized.

Copy link

devinus commented Jul 31, 2015

I wonder why mapSync uses emit rather than queue.

@dominictarr

This comment has been minimized.

Copy link
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 subscribe to this conversation on GitHub. Already have an account? Sign in.