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
102
votes
1 answer

why are folktale and ramda so different?

I'm learning javascript FP by reading DrBoolean's book. I searched around for functional programming library. I found Ramda and Folktale. Both claim to be functional programming library. But they are so different: Ramda seems to contain utility…
Aaron Shen
  • 8,124
  • 10
  • 44
  • 86
46
votes
4 answers

How to convert a hexadecimal string to Uint8Array and back in JavaScript?

I want to convert a hexadecimal string like bada55 into a Uint8Array and back again.
David Braun
  • 5,573
  • 3
  • 36
  • 42
33
votes
2 answers

What's Ramda equivalent to underscore.js 'compact'?

Does Ramda have a function to remove false values from a list? I know we can simply do var compact = R.filter(R.identity); but am I missing the ready-made function?
Dema
  • 6,867
  • 11
  • 40
  • 48
32
votes
3 answers

How can I access iteration index in Ramda.map

I used to write something like _.map(items, (item, index) => {}); with lodash. Usually I don't need index but sometimes it's useful. I'm migrating to Ramda now: R.map((item, index) => {}, items); index is undefined. Sure, I can create variable…
Boris Zagoruiko
  • 12,705
  • 15
  • 47
  • 79
30
votes
12 answers

Sort an array of objects based on another array of ids

I have 2 arrays a = [2,3,1,4] b = [{id: 1}, {id: 2}, {id: 3}, {id: 4}] How do I get b sorted based on a? My desired output would be c = [{id: 2}, {id: 3}, {id: 1}, {id: 4}] I would prefer to use Ramda or regular JS.
ABC
  • 1,387
  • 3
  • 17
  • 28
29
votes
3 answers

Can't wrap my head around "lift" in Ramda.js

Looking at the source for Ramda.js, specifically at the "lift" function. lift liftN Here's the given example: var madd3 = R.lift(R.curry((a, b, c) => a + b + c)); madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] So the first number…
diplosaurus
  • 2,538
  • 5
  • 25
  • 53
25
votes
1 answer

How do I get details of a veracode vulnerability report?

How do I get details of a veracode vulnerability report? I'm a maintainer of a popular JS library, Ramda, and we've recently received a report that the library is subject to a prototype pollution vulnerability. This has been tracked back to a…
Scott Sauyet
  • 49,207
  • 4
  • 49
  • 103
21
votes
1 answer

Differences between Lodash and Ramda

So I've been researching a little bit about JS frameworks. From what I saw, two of the most popular and modern libraries are Lodash and Ramda (right?). I saw a similar question regarding Lodash and Underscore. However, I didn't see anything related…
Jose Andrés
  • 335
  • 3
  • 7
20
votes
2 answers

Ramda js: lens for deeply nested objects with nested arrays of objects

Using Ramda.js (and lenses), I want to modify the JavaScript object below to change "NAME:VERSION1" to "NAME:VERSION2" for the object that has ID= "/1/B/i". I want to use a lens because I want to just change one deeply nested value, but otherwise…
Greg Edwards
  • 598
  • 1
  • 5
  • 12
18
votes
1 answer

RxJS Promise Composition (passing data)

I'm brand new to Rx and am finding it difficult to find documentation on composing promises such that data from the first promise is passed into the second and so on. Here's three very basic promises, the calculations on the data aren't important,…
low_ghost
  • 570
  • 1
  • 5
  • 13
18
votes
5 answers

Handling asynchronous programming with Ramda

I am looking at handling functions that return promises with Ramda functions other then pipeP. I am trying to compare functions (one of which returns a promise) with equals like this: getSectionFromDb :: obj -> promise getSectionFromData :: obj ->…
BBS
  • 1,351
  • 2
  • 12
  • 27
17
votes
3 answers

change an object property in array with ramda

I have an array of the object like below : [{name:'name', key:'21',good: 'true'}, {name: 'another name', key:'22',good:'false'}, ...] now I want to make a change in one of the objects in this array. My first try was this: const s = R.compose( …
amir
  • 2,443
  • 3
  • 22
  • 49
17
votes
4 answers

How to filter out specific keys from object using Ramda?

http://ramdajs.com/0.21.0/docs/#prop Ramda Repl var myObject = {a: 1, b: 2, c: 3, d: 4}; var newObject = R.filter(R.props('a'), myObject); //var newObject = R.filter(R.equals(R.props('a')), myObject); console.log('newObject', newObject); Right…
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
15
votes
2 answers

Good names for flipped versions of `lt`, `lte`, `gt`, and `gte`?

I've been working for some time on a Javascript FP library called Ramda, and I'm having a slight problem with naming things. (You've heard the old line, right? "There are only two hard problems in Computer Science: cache invalidation, naming…
Scott Sauyet
  • 49,207
  • 4
  • 49
  • 103
13
votes
2 answers

How to interrupt, exit a compose or pipe?

What's the proper way to interrupt a long chain of compose or pipe functions ? Let's say the chain doesn't need to run after the second function because it found an invalid value and it doesn't need to continue the next 5 functions as long as user…
Robert Brax
  • 6,508
  • 12
  • 40
  • 69
1
2 3
79 80