Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

flatMap? #73

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

flatMap? #73

wilsonjackson opened this issue Oct 27, 2014 · 6 comments

Comments

@wilsonjackson
Copy link

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

devinus commented Jul 31, 2015

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

@devinus
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
Copy link
Owner

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

@devinus
Copy link

devinus commented Jul 31, 2015

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

@devinus
Copy link

devinus commented Jul 31, 2015

I wonder why mapSync uses emit rather than queue.

@dominictarr
Copy link
Owner

@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.
Projects
None yet
Development

No branches or pull requests

4 participants
@devinus @dominictarr @wilsonjackson and others