Url = “localhost:8080”
connection = open_connection(url)
result = Send_data(connection, data)
raw_response = Get_response(connection)
response = parse(response)
const sendData = R.curry(send_data)(R.__,data)
const result = R.pipe(
open_connection
, sendData
, get_response
,parse
)(url);
@chughes87 I sometimes use something like this:
const log = x => (console.log(x), x)
const pipeLog = (...fns) =>
pipe(log, ...intersperse(log, fns), log)
pipeLog(inc, inc, inc)(0) // logs 0, 1, 2, 3
// also
pipe(dec, dec, log, dec)(100) // logs 98
REPL: https://bit.ly/2QKz2P1
var b = pipe(add(1), tap(console.log), add(1));
b(1); // = 3 (and prints 2)
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?