Transducing
Now, let's consider a performance problem in JavaScript that happens when we're dealing with large arrays and applying several map/filter/reduce operations. If you start with an array and apply such operations (via chaining, as we saw earlier in this chapter), you get the desired result, but many intermediate arrays are created, processed, and discarded—and that causes delays. If you are dealing with short arrays, the extra time won't make an impact, but if you are processing larger arrays (as in a big data process, maybe in Node, where you're working with the results of a large database query), then you will have cause to look for some optimization. We'll do this by learning about a new tool for composing functions: transducing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access