Closed med8bra closed 5 months ago
Hi @antonmedv, what do you think about this one?
But you can already use Promise.all:
echo '[1,2,3]' | fx 'Promise.all(x.map(x=>Promise.resolve(x)))'
That's true. And since fx(Promise.resolve(x)) = x
it would be good UX to have also fx([Promise.resolve(x)]) = [x]
.
As this is easily done with:
echo '[1,2,3]' | fx '.map(x=>Promise.resolve(x))' 'Promise.all(x)'
Let's not merge this PR for now.
What
Currently, fx handles only promise value if it is an output.
This PR improves on that to handle also array of promises and support using
await
in expressions. Which will allow users to perform async operations insidemap
(.i.e:map(x => fetch(x))
).Before
After
Ideas
Maybe fx could introduce a syntax for promises, but I really like the simplicity of
fx
and offloading everything to js runtime, which reduces parse/eval complexity.