我有一个列表,其中包含的项目,如本: [{name:...}, {name:...}], ...
呼叫R.ap的呼叫太多?
我想只提取那些元素,其中name一组正则表达式匹配的任何。
我能够做到这一点,像这样:
const cards = yield ... //Network request to get my list of items
const matchers = [/^Remaining Space:/, /^Remaining Weight:/, /^Gross:/];
const propTester = (prop, pred) => R.pipe(R.prop(prop), R.test(pred));
const extractors = R.ap([propTester('name')], matchers);
const [ spaceCard, weightCard, grossCard ] =
R.ap(R.ap([R.find], extractors), [cards]);
有什么方法来简化?
属性'name'实际上是动态的吗? –