Ramda R.pickBy R.identity 包括零
Ramda R.pickBy R.identity including zeros 0's
简单的问题,我如何通过管道传递 pickBy 身份并包含值为零的道具。目前这个例子会省略零
let linkType = {
name: 'zac',
money: 0,
problems: 'as much as the money'
}
let linksList = R.pipe(
R.pickBy(R.identity),
)(linkType);
如果没有则使用R.either with R.equal(0) to get true
if value equals 0, and the result of 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>
简单的问题,我如何通过管道传递 pickBy 身份并包含值为零的道具。目前这个例子会省略零
let linkType = {
name: 'zac',
money: 0,
problems: 'as much as the money'
}
let linksList = R.pipe(
R.pickBy(R.identity),
)(linkType);
如果没有则使用R.either with R.equal(0) to get true
if value equals 0, and the result of 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>