I have this code:
const compose2 = (f, g) => (...args) => f(g(...args))
const compose = (...fns) => fns.reduce(compose2)
const count = arr => arr.length
const split = str => str.split(/\s+/)
const addAsyncWord = async str => `${str} some words obtained asynchronously`
const read = text => text
const word = compose(
count,
split,
(await addAsyncWord),
read
)
console.log('word ->', await word()) //<- edited
but is throwing the following error:
Uncaught SyntaxError: missing ) in parenthetical
output expected after reading, concat words (obtained from a server randomly, needs to be asynchronously), spliting words, and finally count the total length, must be something similar to this:
word -> 10
How to make this to work? thanks
composeWithandandThen: github.com/ramda/ramda/blob/master/sourcewordis a function that you never call…const compose2 = (f, g) => async (...args) => f(await g(...args)). Anawaitin the arguments list ofcomposewon't achieve anything,addAsyncWordis a function not a promise that can be waited for.