Questions tagged [ramda.js]

Ramda is a functional utility library for Javascript, focusing on making it easy to build modular pipelines out of small, composable functions.

Ramda is a functional utility library for Javascript, focusing on making it easy to build modular pipelines out of small, composable functions.

Functions in Ramda are curried, meaning that if called with fewer than the required number of parameters, they will simply return new (curried) functions that require the remaining ones. Parameter order is different than the native order or the order in libraries such as Underscore or LoDash; those parameters expected to change the most (generally the data being operated on) are supplied last.

Useful Links

1196 questions
4
votes
4 answers

Point-free Function Composition with Ramda.js

I am using Ramda.js for selector functions, to access data in a Redux store. What I want is to define my selectors as functions not referencing the state that the selectors act on, like: const getUserName = path(['user', 'name']); const name =…
William
  • 741
  • 4
  • 9
4
votes
3 answers

Ramda GroupBy - How to group by any prop

given: interface Dict { [key: string]: any } const data: Dict[] = [ { id: 'a' }, { id: 'b', b: 'something' }, { id: 'c', b: 'else' }, { id: 'd', extra: 'hello world' }, { id: 'e' }, ]; where the keys of these Dict objects aren't…
Hitmands
  • 13,491
  • 4
  • 34
  • 69
4
votes
3 answers

How to effectively combine multiple Maybe monads in JavaScript?

I have an object of css rules which can have any or none of the following properties: { 'font-style': '…', 'font-variant': '…', 'font-weight': '…', 'text-decoration': '…', 'vertical-align': '…' } The next step is to build up a css string…
customcommander
  • 17,580
  • 5
  • 58
  • 84
4
votes
2 answers

Unexpected result when using converge to generate all rotations of a list

I'm trying to get all the rotations of the list v. So, in the definition of rotations, I use the flipped version of rotateLeft as the first branching function (in order to accept the list first) and then a function that returns the list [0, 1, 2,…
Louis Sakh
  • 43
  • 4
4
votes
2 answers

ImmutableJS vs Ramda or ImmutableJS + Ramda - can they be used together

I'm exploring these two libs and for me ImmutableJS has (mostly) immutable data structures whereas Ramda has swiss army knife set of FP utils. When I google I see articles like Ramda vs ImmutableJS that recommend one or the other, but at first…
dragonfly
  • 17,407
  • 30
  • 110
  • 219
4
votes
1 answer

JavaScript functional programming: How to handle fetch (for pipes)

I'm currently learning functional programming in JavaScript. I use ramda as a helper library to write helpers such as asyncPipe: import { pipeWith, then } from 'ramda'; export const asyncPipe = pipeWith(then); To log the user in I have to make an…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
4
votes
2 answers

Ramda: Is there a way to 'fork' a parameter to two functions during pipe?

I'm a functional programming beginner. I'm working on a React Native app using Ramda. The app lets users maintain their houses. I have written function called asyncPipe which lets me pipe promises and normal functions. I use it for the loginFlow…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
4
votes
1 answer

Merge three arrays with ramda

I've recently started using Ramda to work with responses from JSONAPI and I am having some trouble dealing with complex relationships.. I have a big array with three smaller arrays, and I need to merge the three smaller arrays, but each array has a…
user10022985
4
votes
1 answer

Ramda, array equality regardless of order

When comparing arrays, the ramda equals will return true only if two arrays hold the same values in the same order. I need a function to check if two arrays hold exactly the same values, but ignore the order in which the values occur. For now I am…
devboell
  • 1,180
  • 2
  • 16
  • 34
4
votes
4 answers

What's the cleanest fp way to get a property pointed by another property

Given an object that may be null and may have the following properties: { templateId: "template1", templates: { template1: "hello" } } How would you get the template in a failsafe way? (templateId might not be defined, or the…
Tiago Coelho
  • 5,023
  • 10
  • 17
4
votes
2 answers

difference between chain() and map() in ramda.js

What is the difference between chain() (from ramda package) and map() in Javascript? In both functions the programmer inputs an object and some lambda/function and gets a certain calculation of it. Thanks.
J. Doe
  • 95
  • 8
4
votes
5 answers

Is there a name for this function

I am looking for a name for the following function: (f, a) => () => f(a) Basically a function that returns a function which when called calls f with a. Is there a common name for this function? maybe it can be described with some Ramda magic? Edit…
Sam Pettersson
  • 3,049
  • 6
  • 23
  • 37
4
votes
2 answers

Filter object array based on another - Ramda functional style

let arr = [ { id: 100, name: 'bmw' }, { id: 101, name" 'porsche' } ]; let selected = [{id: 100}]; What is the Ramda way of getting a filtered list F based on the inputs (list, selected)?
user898788
  • 109
  • 7
4
votes
3 answers

Make R.pipe work with a Promise?

Background I have a simple code that composes functions to print Hello Mars!: var greeting = () => "Hello "; var dbQuery = str => Promise.resolve( `${str} Mars` ); var phrase = R.pipeP( greeting, dbQuery, R.flip( R.concat…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
4
votes
2 answers

Ramdajs keyBy equivalent of lodash

I have an array that I want to transform into an object. For example: const arr = [{id: 1, key: ''}, {id: 2, key: ''}]; I want the result to be: const object = { 1: {id: 1, key: ''}, 2: { id: 2, key: ''}} With lodash I can use the keyBy function,…
undefined
  • 6,366
  • 12
  • 46
  • 90