简体   繁体   English

双方的拉姆达否定

[英]Ramda Negation In Both

Why does the following fail to return a function? 为什么以下代码无法返回函数?

const isValid = both(not(isEmpty), is(Object));

The item is valid if it: 该项目在以下情况下有效:

  1. Exists 存在
  2. Is an Array 是一个数组
  3. Is not empty 不为空

As mentioned in my comment, not is, ahem, not what you want. 如我的评论所述, not不是不是您想要的。 Instead, try complement : 相反,尝试complement

 const isValid = R.both(R.complement(R.isEmpty), R.is(Array)); console.log(isValid); console.log(isValid([1,2,3])); 
 <script src="https://cdn.jsdelivr.net/npm/ramda@latest/dist/ramda.min.js"></script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM