[Ramda] Simple log function for debugging Compose function / Using R.tap for logging

const log = function(x){
  console.log(x);
  return x;
}

const get = R.curry(function(prop, obj){
  return obj[prop];
})

var people = [
  {name: "Wan"},
  {name: "Zhentian"}
];

var res = R.compose(
  get('name'),
  log,
  R.head
)(people);

console.log(res);

Using R.tap:

const log = curry((desc, x) => R.tap(() => console.log(desc, JSON.stringify(x, null, 2)), x));
原文地址:https://www.cnblogs.com/Answer1215/p/5838513.html