是否有 ramda 函数可以帮助您将日志记录添加到 piping/composition?

Is there a ramda function that helps you add logging to piping/composition?

我想将日志记录添加到像这样的组合函数链中

const f = R.compose(
  transformation2,
  doAlso(x => console.log(`id: ${x.id}`)),
  transformation1
)

这将首先应用 transformation1,然后在将结果值传递给 transformation2 之前记录结果值的 ID。

实施起来会很容易

doAlso = f => x => {
  f(x)
  return x
}

但它似乎应该是一个很常见的模式。这个概念叫什么?像 ramda 这样的 FP 库中是否存在类似的功能?

这个函数在 Ramda 中被称为 tap