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

1032 questions
97
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
  • 7,354
  • 8
  • 40
  • 76
29
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…
Glen Swift
  • 10,962
  • 14
  • 43
  • 73
29
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,697
  • 10
  • 38
  • 47
26
votes
3 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
  • 4,607
  • 2
  • 31
  • 41
26
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,334
  • 4
  • 19
  • 44
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
  • 578
  • 1
  • 5
  • 11
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,201
  • 2
  • 11
  • 23
17
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
  • 538
  • 1
  • 5
  • 13
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
  • 37,179
  • 4
  • 36
  • 82
13
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
  • 1,986
  • 3
  • 17
  • 44
13
votes
1 answer

Apply a list of functions to a value in Ramda

How would I best create this function in Ramda? function get_list (value) { return [ first_transform(value), second_transform(value) ] } get_list(12) I guess this is the inverse of the map function.
MattMS
  • 996
  • 1
  • 12
  • 28
12
votes
5 answers

Point-free style capitalize function with Ramda

While writing a capitalize function is trivial, such that: "hello" => "Hello" "hi there" => "Hi there" How would one write it using point-free style using Ramda JS? https://en.wikipedia.org/wiki/Tacit_programming
Tutan Ramen
  • 1,129
  • 1
  • 7
  • 23
11
votes
2 answers

Pointfree recursion in JS with ramda

I am learning about pointfree functions and am trying to implement this recursive null remover in that style. Works, but is not pointfree: function removeNulls(obj) { return R.ifElse( R.either(R.is(Array), R.is(Object)), R.pipe( …
11
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
  • 4,735
  • 8
  • 32
  • 60
11
votes
3 answers

Convert array of objects to plain object using Ramda

How can I convert an array of objects to a plain object? Where each item of the array is an object with only one key:value pair and the key have an unknown name. I have this const arrayOfObject = [ {KEY_A: 'asfas'}, {KEY_B: 'asas' } ] let…
matiasfha
  • 1,220
  • 4
  • 23
  • 42
1
2 3
68 69