".map" over console.log does not seem to show the stream
See original GitHub issueSummary
The following code does not seem to show the stream:
from([1,2]).map(x=>console.log(x))
Expected result
Expected: 1
followed by 2
in the console
Actual Result
In the Node REPL:
Stream {
source: Map { f: [Function], source: ArraySource { array: [Object] } } }
Versions
node@6.9.2
- most.js: <version> most@1.3.0
Steps to reproduce
Node REPL
node
>most = require('most')
>most.from([1,2]).map(x=>console.log(x))
//=> Stream {
source: Map { f: [Function], source: ArraySource { array: [Object] } } }
Code to reproduce
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Why flatMap has no output when one stream has error?
Why flatMap has no output when one stream has error? ... I tried to write a program with highland.js to download several files,...
Read more >Why map with console.log doesn't work - gists · GitHub
It works because map isn't being assigned to a variable, but I think the more proper way would be using forEach, as map...
Read more >Console app not showing info and debug logs
I've tried running the Console app as root, via sudo from the command line and the same issue occurs; no debug or info...
Read more >Node.js v19.3.0 Documentation
Commands in this document start with $ or > to replicate how they would appear in a user's terminal. Do not include the...
Read more >View and save your browser console logs - Zapier Help
In rare instances, after you've contacted support we may need to see logs from your browser's console to see how it is interacting...
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 FreeTop 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
Top GitHub Comments
@dmitriz As @TylorS explained,
observe (f, stream)
is reallydrain(tap(f, stream)
.f
is your provided function that will perform a side effect on each item in the stream. Any return value off
is ignored.tab
will then return a new stream with the same items as in the originally provided stream. The new stream is passed todrain
, which returns aPromise
. ThisPromise
either fulfills when the stream ends without an error or is rejected if the stream ends with an error. Take note that the events of the stream are time-ordered.Thus, if you have an “infinite” stream, e.g., a source that emits an event periodically, the provided function
f
will fire on every event, performing whatever side effect specified. Logically, the returnedPromise
will neither resolve nor reject (granted no errors occurred). After all, the stream is “infinite”. If the stream was finite (it ends), the code will then choose the path of either resolved or rejectedPromise
, if you so choose. As you see, the events are still consumed and passed tof
.You can easily
map
over the stream as in flyd, but you still need to consume the stream:Hope this helps (and that I didn’t provide any incorrect information in my explanation).
@dmitriz The original issue here seems to be resolved (observing the stream activates it), and it seems like @davidchase’s suggestion of looking at most-subject was helpful for your subsequent questions. So, I’m closing, but please re-open or create a new issue if there’s more we need to discuss.
Cheers!