The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Build a Functional Pipeline with Ramda.js

Build a Functional Pipeline with Ramda.js

5:37
We'll learn how to take advantage of Ramda's automatic function currying and data-last argument order to combine a series of pure functions into a left-to-right composition, or pipeline, with Ramda's pipe function.
Watch this lesson now
Avatar
egghead.io

We'll learn how to take advantage of Ramda's automatic function currying and data-last argument order to combine a series of pure functions into a left-to-right composition, or pipeline, with Ramda's pipe function.

Avatar
Charles

the code in CODE TAB does not reflect what the presenter in the video was teaching. Is there a reason why/

Avatar
Andrew Van Slaars

Charles,

First of all, thanks for watching!

The code in the code tab does have a couple of slight differences, but the core result of the lesson is represented. The key differences are that in the video, I am running the code with Node and use a require to import the library. In the embedded example, Ramda is being pulled into the browser through a script tag.

The second difference is that there is an additional line at the bottom of the code sample, simply for the purpose of showing the results in the result pane rather than forcing you to open your console.

The third difference is that the commented out version of the code has been removed from the embedded example for clarity.

I hope this helps and thanks again for watching!

In reply to Charles
Avatar
Sen

Slightly concise version using reduce.

const findTopTeam = R.reduce((a,b) => a.score > b.score ? a : b, {score: 0})
const getName = R.prop('name')
const getTopName = R.pipe(findTopTeam, getName)
Avatar
Andrew Van Slaars

Sen,

Nice optimization!

In reply to Sen
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?