Inspecting With Tap
Explore how to use tap in RamdaJS to inspect values within function pipelines built with pipe and compose. Understand how tap aids debugging by allowing you to introduce logging or side effects without affecting the data stream, enhancing your ability to troubleshoot functional code.
We'll cover the following...
One of pipe's potential drawbacks is losing the ability to easily add code for debugging purposes.
Back when we had this
Jamming a console.log or little hack was easy. How do we inspect piped functions?
Introducing tap. It takes a function, usually a logger, and supplies it the current value. You can do whatever you want without affecting the pipeline since you’re just “tapping” it! :D
You don’t even need to use tap itself, just insert a function that returns its arguments unchanged.