这显然不起作用 - 因为always
不会像whenTrueValue
那样在whenPropTrueAlways
的顶级实现中调用export const whenPropEq = curry((key, predicateValue, whenTrueFn, data) =>
when(
propEq(key, predicateValue),
whenTrueFn,
)(data),
);
const whenPropTrueAlways = curry((key, whenTrueValue, data) =>
whenPropEq(key, true, always(whenTrueValue), data),
);
// Doesn't work, for obvious reasons- just trying to illustrate the desire
const whenPropTrueAlways = whenPropEq(__, true, always(__), __);
。有没有办法操纵调用另一种方法,就像我试图做的那样?将特定值替换为参数,以及将函数应用于另一个参数?
computed: {
uniquePosts: function() {
var output = [];
var keys = [];
this.posts.forEach(function (post) {
var key = post[keyname];
if (keys.indexOf(key) === -1) {
keys.push(key);
output.push(post);
}
});
return output;
}
}
提前感谢您的帮助。