flatMap and flow-based programming in Highland
See original GitHub issueIn this contrived example, I loop the output stream of the input back into itself creating a recursion-like behavior. It produces 1, 2, 4, 8, 16, 32, 64, 128, 256, 512.
_ = require('highland')
input = _([1])
input
.doto((v)-> console.log(v))
.map((v)-> v * 2)
.filter((v)-> v <= 512)
.pipe(input)
This doesn’t seem to work if I use a flatMap. It will only print out the first value, 1. My goal here is that I would like to return multiple values for each input value.
_ = require('highland')
input = _([1])
input
.doto((v)-> console.log(v))
.flatMap((v)-> return H([v * 2]))
.filter((v)-> v <= 512)
.pipe(input)
Is this a bug or is there something I need to do differently when using a flatMap?
Issue Analytics
- State:
- Created 8 years ago
- Comments:17
Top Results From Across the Web
Highland.js
Re-thinking the JavaScript utility belt, Highland manages synchronous and asynchronous code easily, using nothing more than standard JavaScript and Node-like ...
Read more >An Empirical Evaluation of Flow Based Programming in ... - arXiv
This paper proposes to consider Flow-Based Programming (FBP) as a paradigm for creating DOA applications. We empirically evaluate FBP in the ...
Read more >Functional Geekery Episode 22 – LambdaConf 2015, Part 1
Programming and Math talk. Perspective on the functional programming community at LambdaConf. Interest in Clojure and Scala ...
Read more >Generators | Scramjet
Scramjet brings generator and iterator protocol support to node.js streams and makes them easy to use as callbacks to standard methods.
Read more >All | Alexito's World
But with patience, and thanks to the constant flow of time, California o'clock arrived and ... Casey Muratori, about Object Oriented Programming 5...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I thought about it some more, and there’s a way to do recursion while still maintaining the
returnPipe
approach.It doesn’t look like a flow network but accomplishes the same thing.
Edit:
process
->transform
.Oops! Fixed.