I have the following:
{ reseller: filterOutNonUsable(dedupe(extractArrVals(data.locks.entries, 'reseller'))) }
What is the best way to call all these functions and use a second parameter for the extractArrVals function (see my example) so that I can use 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')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.