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

Ramda with FP Types

Recently I have decided to switch from lodash to ramda to play with functional way of composing my logic. I love it! After some extensive digging into FP I have found that's it's not only about handy pure/point free utilities (ramda), but more about…
6
votes
7 answers

Functional programming: Return first truthy result of calling a list of different functions with a specific argument

I'm venturing into trying to use functional programming in TypeScript, and am wondering about the most idiomatic way of doing the following using functional libraries such as ramda, remeda or lodash-fp. What I want to achieve is to apply a bunch of…
Jimbali
  • 2,065
  • 1
  • 20
  • 24
6
votes
4 answers

Ramda: Fold an object

I'm building a PWA and build by logic with Ramda. I'm trying to build a function that given a Google Places Detail response returns a custom address object. Let me describe it in code by showing you my test: assert({ given: 'a google places api…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
6
votes
1 answer

Typescript: How to type Ramda R.prop(key) T' is not assignable to parameter of type '(s: {}) => {}

Typescript error (method) R.Static.prop(p: string): (obj: Record) => T (+3 overloads) Returns a function that when supplied an object returns the indicated property of that object, if it exists. Argument of type '(obj: Record) => T' is not…
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
6
votes
1 answer

How do I use compose in Typescript?

Im having problems using compose in Typescript.... const rawHeaders = R.compose( R.join('\n'), R.map(x=>`${x[0]}: ${x[1]}`), R.toPairs ) I have tried the below, but it's brutal. Anyone know a way to make this work more elegantly? const…
thomas-peter
  • 7,738
  • 6
  • 43
  • 58
6
votes
3 answers

When is it appropriate to choose point-free style vs a data-centric style in functional programming?

In case it matters this is about functional programming in JavaScript and in my examples I’ll be using Ramda. While everybody at work has fully embraced functional programming, there’s also a lot of discussions around how to do it “right”. These two…
customcommander
  • 17,580
  • 5
  • 58
  • 84
6
votes
3 answers

Import { map } from 'lodash', 'rxjs', 'ramda' at the same time without hurting readability

How does one import map or merge or any other function from multiple imports? import { map } from 'lodash'; import { map } from 'rxjs/operators'; import { map } from 'ramda'; The obvious answer is to: import { map as _map } from 'lodash'; import {…
Dolan
  • 1,519
  • 4
  • 16
  • 36
6
votes
4 answers

How do you sort an array of words with Ramda?

Sorting numbers is easy with Ramda. const sizes = ["18", "20", "16", "14"] console.log("Sorted sizes", R.sort((a, b) => a - b, sizes)) //=> [ '14', '16', '18', '20' ] Sorting an array of words with vanilla javascript is too. const trees =…
Sifnos
  • 1,161
  • 2
  • 13
  • 22
6
votes
2 answers

How can I use Ramda's omit() function on a deeply nested object member in javascript

I have a situation where I want to remove any part of an object tree before flattening and exporting to CSV. Ramda is my choice library for FP in JS, but I noticed the R.omit() function works at only one level deep of the target object. How can I…
kennasoft
  • 1,595
  • 1
  • 14
  • 26
6
votes
1 answer

Is Ramda ifElse an effective pattern if it abstracts a ternary operation

Risky question to be opinionated. I'm working on a project with Ramda.js. And I see many ifElse calls throughout the code. const getEvent = R.ifElse( fireable, R.always(sendAnalyticsEvent), R.always(R.always(undefined)) ); Is this really…
Lex
  • 4,749
  • 3
  • 45
  • 66
6
votes
4 answers

Nested map of arrays the FP way

Given the following arrays: const array1 = ["a1", "b1", "c1", "d1"], array2 = ["a2", "b2"], array3 = ["a3", "b3", "c3"] Is there any ramda function to simplify the following scenario on which I could give one or more arrays? const…
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
6
votes
2 answers

Use Fluture with Ramda

I was using Bluebird for doing asynchronous stuff, but now have to do a lot of empty / null / error checks and I don't want to go down the usual if Else route. Am thinking of using monads, but have not yet grokked it completely. Also I want it to…
jgr0
  • 697
  • 2
  • 6
  • 20
6
votes
2 answers

Axios serving png image is giving broken image

I am using express as middle-ware api.A person hits my middle-ware , it hits some third party api and returns back the result. Its working fine for all other end points expect an get end point that creates an png and serves it. so under method…
Dhruv Pal
  • 849
  • 2
  • 10
  • 25
6
votes
2 answers

Ramda.js Combine two array of objects that share the same property ID

I have these two array of objects todos: [ { id: 1, name: 'customerReport', label: 'Report send to customer' }, { id: 2, name: 'handover', label: 'Handover (in CRM)' }, ] And: todosMoreDetails:…
Anonymous
  • 1,021
  • 2
  • 10
  • 24
6
votes
1 answer

import R (ramda) into typescript .ts file

I am attempting to use Ramda.js as follows: /// module App { var settab = R.once((element) => current(element)); function current(li: any) { // ... } } I…
Jim
  • 14,952
  • 15
  • 80
  • 167