将参数传递给下一个函数的函数

Function that passes arguments to the next function

是否有 ramda 函数接受函数参数并将其传递给在该范围内调用的下一个函数?

我想在不使用箭头函数的情况下实现这样的效果:

R.allPass([x => R.not(R.isEmpty(x)), R.isNil])(data)

它可能看起来类似于这个:

const passArgument = (func, func2) => arg => func(func2(arg));

R.allPass([passArgument(R.not, R.isEmpty), R.isNil])(data)

R.compose 是您要的功能。

R.allPass([R.compose(R.not, R.isEmpty), R.isNil])(data)

还有R.pipe从左到右组合函数

对于这个特定示例,您可能还对 R.both and R.complement 感兴趣,它可以实现为:

R.both(R.complement(R.isEmpty), R.isNil)

我不完全确定你是否会找到既 null/undefined 又非空的东西,尽管它的计算结果是 true