[英]Use compose with several functions and inner function with param
我有以下內容:
{ reseller: filterOutNonUsable(dedupe(extractArrVals(data.locks.entries, 'reseller'))) }
調用所有這些函數並為 extractArrVals function 使用第二個參數的最佳方法是什么(請參閱我的示例),以便我可以使用https://www.30secondsofcode.org/snippet/compose ?
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const extractArrVals = (obj, key) => {
/////YOUR FUNCTION
};
const dedupe = (data) => {
/////YOUR FUNCTION
}
const filterOutNonUsable = (data) => {
/////YOUR FUNCTION
}
// transformer or whatever it's name
const transformer = compose(
filterOutNonUsable,
dedupe,
extractArrVals
);
transformer(data.locks.entries, 'reseller')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.