Ramda is a JavaScript functional library whose functions are conventionally accessed through the R namespace. It supports loosely coupled pipelines and modular programs built from independent functions. section 4.0 section 4.3
Its most developed use here is currying: R.curry turns a function with several parameters into a sequence of calls that returns another function until all arguments arrive. section 4.3
Choosing a data source with a curried function
const fetchStudentFromDb = R.curry(function (db, ssn) { return find(db, ssn); }); const fetchStudentFromArray = R.curry(function (arr, ssn) { return arr[ssn]; }); const findStudent = useDb ? fetchStudentFromDb(db) : fetchStudentFromArray(arr); findStudent('444-44-4444'); The first call fixes the data source; the returned function accepts a student identifier. The same pattern also creates reusable logging functions by partially applying R.curry(logger). section 4.3
