Functional programming 有没有办法将这个异步函数重构为无点的?
我有这个功能:Functional programming 有没有办法将这个异步函数重构为无点的?,functional-programming,ramda.js,Functional Programming,Ramda.js,我有这个功能: const getData = async player => { const [profile, repos] = await Promise.all([ getProfile(player), getRepos(player) ]) return { profile, repos } } 我可能不需要更改它,但我只是想知道是否有可能使用Ramda使其成为无点模式。我认为您已
const getData = async player => {
const [profile, repos] = await Promise.all([
getProfile(player),
getRepos(player)
])
return {
profile,
repos
}
}
我可能不需要更改它,但我只是想知道是否有可能使用Ramda使其成为无点模式。我认为您已经清楚地表达了意图,而重构到无点模式可能会使事情变得混乱 也就是说,这可能是一个什么样的例子:
const getProfile=player=>Promise.resolve('player-'+player)
const getRepos=player=>Promise.resolve('repo-'+player)
常数fn=R.pipe(
R.pipe(R.juxt([getProfile,getRepos]),Promise.all.bind(Promise)),
R.zipObj(['profile','repos']))
)
fn('foo')。然后(console.log)