const DEBUG_MODE = true;
let debugTimestamps: { [label: string]: number }[] = [];
const debugPipe = (label: string) => <T>(input: T) => {
if (DEBUG_MODE) {
debugTimestamps = [
...debugTimestamps,
{
[label]: performance.now(),
},
];
console.log({ [label]: input });
}
return input;
}
startDebug
or endDebug
that basically just grabs the debugTimestamps and prints the performance numbers
C
combinator I believe it is called
flip
is very useful when you have to use other libs/apis that are not set up for easy composition with the data last format (or in cases where your data is the key name). But very handy tool in your belt, none the less
const fn = R.prop(R._, x)
I believe?
Hi all!
I come here to ask you what do you think is the best way to reduce two lists at once?
Supposing that the two lists are exactly the same length, how could I reduce over list1, access the current item (with index usually) and get the value at that same index in list2.
In plain JS, I would usually use the index
from the callback, but it see that ramda works differently. I'd like to What do you think?
someone told me a good practice for composing sorter functions is that if they return 0 it delegates to the next function, i defined this as
const pipeCritera = (...fns) => (a, b) => (fns.find(f => f(a, b) !== 0) || (() => 0))(a, b);
essentially returning the value of the first sorting function that doesnt return 0,
now im wondering if ramda already has this covered
this
and other bit to make it more Java-like. That is why, from my understanding things like closure scope and first class functions are at the core. Which are the only (2) features that are required to be a functional language