nth
: R.pipe(
R.toPairs,
R.filter(R.pipe(
R.nth(1) as (value: [string,string]) => string,
R.both(R.pipe(R.isNil, R.not), R.pipe(R.startsWith('workspace:'), R.not))
) as (v: [string,string]) => boolean),
R.fromPairs
) as (data: Record<string,string>) =>Record<string,string>
Hi, I am having this problem with TS type. Do you have any idea?
error
No overload matches this call.
The last overload gave the following error.
Argument of type 'concat_list_10<File>' is not assignable to parameter of type 'Morphism<unknown, unknown>'.
Types of parameters 'b' and 'value' are incompatible.
Type 'unknown' is not assignable to type 'unknown[]'.ts(2769)
over.d.ts(106, 5): The last overload is declared here.
The code
const updateFiles = R.concat(files)
set(state => {
return R.over(lensFiles, updateFiles, state)
})
export interface File {
id: string;
link: string
}
interface
```export interface UserData {
_id: string | undefined;
files: File[];
}
state example
const state = {
user: { data: {
id: 1,
files : [{id:"1", link: "somelink"}]
}}
}
Version
"ramda": "^0.27.1",
"@types/ramda": "types/npm-ramda#dist",
const filterFns = pipe(
reject(pipe(values, head, isNilOrEmpty)),
... // some other code, not important for now
])),
)([...$or, ...$and]);
pathTo
and isNilOrEmpty
are helpers in our code based on Ramda...
R.contains
with R.includes
at https://ramdajs.com/docs/#onError: './src/curry' is not defined
at RunKit
I am having an issue understanding next lens code:
import {compose, lensProp, view} from "ramda";
const truth = compose(
lensProp('foo'),
lensProp('bar'),
lensProp(1),
)
const obj = {
foo: {
bar: [false, true]
}
};
console.log(view(truth, obj)) // true
I could understand if we used pipe instead of compose, but compose performs right-to-left function execution and that confuses me.
const fetchPlanets = async (url) => await fetch(url);
const checkResponse = (response) => response.ok ? response : 'error';
const getJson = async (response) => await response.json();
const logger = data => console.log(data);
const gettingData = pipe(
fetchPlanets,
checkResponse,
getJson,
logger
)
gettingData('https://swapi.dev/api/planets');
Hi! I'm using Ramda in a project and editing with VSCode. I'm trying to document my code with JSDoc but VSCode's Intellisense automatically infers my function types (so doesn't show my JSDoc comments). Does anyone know how to force VSCode to stop inferring if there is JSDoc documentation?
/**
* @param { Array<Number> } arrayOfNumbers
* @return { Number } sum - the sum of the arrayOfNumbers
*/
const getSumOfArrayElements = reduce (add, 0)
Intellisense just shows what R.reduce
returns:
const getSumOfArrayElements: (list: readonly any[]) => number
Asking here because I figure other Ramda users may have run into this. Thanks!
I don’t know what I have to do facing the following error concerning type.
Could someone help me with this?
Code
import { concat, flip, pipe } from 'ramda'
const concatAfter = flip(concat)
const foo = [1, 2, 3]
const bar = [4, 5, 6]
type Exec = (x:number[]) => number []
const exec:Exec = pipe(
concatAfter(foo),
concatAfter(bar)
)
Error
[tsserver 2322] [E] Type '(s2: string) => string' is not assignable to type 'Exec'.
Types of parameters 's2' and 'x' are incompatible.
Type 'number[]' is not assignable to type 'string'.
Packages
ramda@0.28.0
@types/ramda@0.27.64
flip
, and write type explictly:const concatAfter = (list1: number[]) => (list2: number[]) =>
concat(list2, list1);
const foo = [1, 2, 3];
const bar = [4, 5, 6];
type Exec = (x: number[]) => number[];
const exec: Exec = pipe(concatAfter(foo), concatAfter(bar));
@types/ramda
and I made a code sandbox with some code here https://codesandbox.io/s/youthful-borg-rh1d4b?file=/src/index.tsNo overload matches this call.
. I'm not really sure what it's trying to tell me... has anyone encountered something similar before?
Can you explain me why ramda does not work with plain objects in typescript? ```const name1 = R.prop("name", { test1: 1, name: "Ivan" }); //works
const extractName = R.prop("name");
const name2 = extractName({ test1: 1, name: "Ivan" }); //typescript complains
const obj = { test1: 1, name: "Ivan" };
const name3 = extractName(obj); //works
```
Hey guys, given an array of numbers, I need to partition elements by difference to their preceding element. Example:
const difference = 10;
const elements = [0,5,10,15,20,30,35];
// desired result:
[[0,5,10,15,20], [30, 35]]
Is there something in the library that allows looking at the previous element's value when iterating?
What is a functional way to find a specific size object from this kind of nested data structure. For example, I want to iterate until I find a size { id: 6 }
and return it. Do I have to use 3 nested loops?
Input:
[
{
id: 'a',
colors: [
{
name: 'blue',
sizes: [
{ id: 1 },
{ id: 2 },
//...
]
},
{
name: 'green',
sizes: [
{ id: 3 },
{ id: 4 },
//...
]
},
//...
]
},
{
id: 'b',
colors: [
{
name: 'black',
sizes: [
{ id: 4 },
{ id: 6 },
//...
]
},
{
name: 'white',
sizes: [
{ id: 7 },
{ id: 8 },
//...
]
}
]
},
//...
]
I'm sure a number of you may have already heard but there is a new ECMAScript proposal for "Types as Comments". It's basically a way to allow TypeScript and Flow code to run in the browser as is. It's just Stage 0 and might get shelved before ever making it somewhere but the interesting thing is that it's being pushed by representatives from Microsoft and it already has some heavy hitters from the ECMAScript proposal community engaging with it. As we all know, using TS for functional programming has some frustrating limitations and hoops to jump through. So I just want to make sure the functional JS is community aware of the proposal and encourage people to go explore the proposal and speak up so we're represented in the discussion.
Thanks!
is there something like until
but returning array of all values instead of last one?
like in example
R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
it would return [1,2,4,8,16,32,64,128]
ok I found unfold
const f = n => n > 100 ? false : [n, n * 2];
R.unfold(f, 1); // =>[1,2,4,8,16,32,64]
```