我有一個列表,其中包含的項目,如本: [{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'實際上是動態的嗎? –