简单的问题,如何管道pickBy标识并包含值为零的props。目前这个例子会省略零
let linkType = {
name: 'zac',
money: 0,
problems: 'as much as the money'
}
let linksList = R.pipe(
R.pickBy(R.identity),
)(linkType);
答案 0 :(得分:3)
如果值等于0,则使用R.either和R.equal(0)获取true
,如果不是,则使用R.identity的结果:
const linkType = {
name: 'zac',
money: 0,
problems: 'as much as the money',
another: false
}
const linksList = R.pickBy(R.either(R.equals(0), R.identity))(linkType);
console.log(linksList);
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.js"></script>