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
6
votes
4 answers

Comparing partial objects in ramda.js

There is an equals function in Ramdajs which is totally awesome, it will provide the following: // (1) true R.equals({ id: 3}, { id: 3}) // (2) true R.equals({ id: 3, name: 'freddy'}, { id: 3, name: 'freddy'}) // (3) false R.equals({ id: 3, name:…
Jim
  • 14,952
  • 15
  • 80
  • 167
6
votes
3 answers

Functional approach of removing items in a list based on nested property values

I am trying move more towards functional programming in my javascript applications. I currently use the library ramda as a base lib for this. My desire: Create a function removeUserFromList(username, list) which returns the items in the list that…
horte
  • 403
  • 4
  • 8
5
votes
1 answer

LensProp Type Definition of Ramda

When using Ramda's lensProp like: R.lensProp('x') I'm getting this error: Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345)
Y M
  • 2,105
  • 1
  • 22
  • 44
5
votes
3 answers

Pointfree dynamic function composition

I'm trying to refactor this function to be pointfree. function siblings(me) { return R.pipe(family, R.reject(equalsMe(me)))(me); } I'd like to pass me to a function down the pipe along with the value that family returns. Tried a few things with…
AKG
  • 2,936
  • 5
  • 27
  • 36
5
votes
2 answers

Using Promise.all inside a Ramda pipe

How is Promise.all used in a ramda pipe? I think I'm missing something silly here. const pipeline: Function = R.pipe( R.map((record) => record.body), R.map(JSON.parse), R.map(asyncFunction), console.log ); Returns an array of…
Mmm Donuts
  • 9,551
  • 6
  • 27
  • 49
5
votes
1 answer

Lodash.get equivalent in Ramda

Is there any built-in Ramda function to retrieve the value giving the path as a string? Like: R.path('a.b', {a: {b: 2}}); // I want to get 2 I know that this is possible with path by using an array, like: R.path(['a', 'b'], {a: {b: 2}}); I can…
Emi
  • 4,597
  • 2
  • 31
  • 34
5
votes
5 answers

Is there a Variadic Version of either (R.either)?

I have a need for a variadic version of R.either. After doing some searching around the web, I have not found a solution. R.anyPass would work but it returns a Boolean instead of the original value. Is there already a solution that I have…
5
votes
5 answers

Rename keys with ramda js

const orignalArr = [ { personName: 'Joe' } ] expected output: const convertedArr = [ { name: 'Joe' } ] I'm thinking the renamed keys are defined in an object (but fine if there's a better way to map them): const keymaps = { …
Joe
  • 4,274
  • 32
  • 95
  • 175
5
votes
9 answers

creating top 5 aggregation with ramdajs

I would like to transform this input [ { country: 'France', value: 100 }, { country: 'France', value: 100 }, { country: 'Romania', value: 500 }, { country: 'England', value: 400 }, { country: 'England', value:…
Pierre-Jean
  • 1,872
  • 1
  • 15
  • 21
5
votes
5 answers

nodejs functional programming with generators and promises

Summary Is functional programming in node.js general enough? can it be used to do a real-world problem of handling small bulks of db records without loading all records in memory using toArray (thus going out of memory). You can read this criticism…
Muayyad Alsadi
  • 1,506
  • 15
  • 23
5
votes
3 answers

Filter out unique nested values using ramda

I have a collection of UNIX timestamps that looks like this: [ {"start_time":1540458000000, "end_time":1540472400000}, {"start_time":1540458000000, "end_time":1540486800000}, {"start_time":1540458000000, "end_time":1540501200000}, …
gosseti
  • 965
  • 16
  • 40
5
votes
1 answer

using the fetch api with ramda

I'm learning Ramda and try to reach pointfree programming. In order to do that, I try to refactor here and there but got stuck on this. I obviously think this doesn't work because the call is asychronous but I could not find what is wrong with this…
3Dos
  • 3,210
  • 3
  • 24
  • 37
5
votes
1 answer

Spreading array over Ramda's pipe function gives type error "Expected 1-6 but got 0 or more"

I'm at a loss as to how I can make this work. I'm defining a function in typescript that essentially wraps Ramda's pipe function. I want to accept values that may or may not be functions, wrap the non-function values in constant functions, and…
5
votes
1 answer

How can I generically type variable bindings in TypeScript?

I have a generic interface available to me as such: CurriedFunction3: R I would like to create a const binding that fills in some of those type arguments. Something like this: type CurriedSorter = CurriedFunction3<(obj: T) => any,…
knpwrs
  • 15,691
  • 12
  • 62
  • 103
5
votes
1 answer

How to use Ramda pipe?

Background I am trying to compose 2 functions using Ramda, but I am having issue with pipe, meaning I don't know how to use it. Code Let's imagine I have a function that returns an array: var createQuery = params => [ getSQLQuery( params ), […
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266