Ramda

In a real-world application, we don't need to create our own our FP utilities (for example, compose or curry functions). We can use existing JavaScript libraries that already implement these helpers and many others. One of these libraries is Ramda.

We can install Ramda using npm:

npm install --save ramda npm install --save-dev @types/ramda 

Ramda includes helper functions to implement function composition, currying, and many more FP techniques, and its API is influenced by the pointfree style.

The following code snippet re-implements the example that we used earlier in this chapter in the Currying section but uses the Ramda implementations of compose and currying, instead of using custom implementations:

import * as R from "ramda";const ...

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.