javascript - Why was await* removed from the async/await proposal? -
the place seems documented this issue thread , the actual specification. however, reasoning removal isn't posted anywhere find.
the new recommended way seems await promise.all()
, i'm curious why await*
removed.
well, last revision of readme before removed mentions in paragraph:
await* , parallelism
in generators, both
yield
,yield*
can used. in async functions,await
allowed. direct analogoue ofyield*
not make sense in async functions because need repeatedly await inner operation, not know value pass each await (foryield*
, passes in undefined because iterators not accept incoming values).it has been suggested syntax reused different semantics - sugar
promise.all
. accept value array of promises, , (asynchronously) return array of values returned promises. expected 1 of common promise-related oprerations not yet have syntax sugar after core of proposal available.
so it's no direct analogue yield*
1 might expect, doesn't make sense, suggestion never included in spec proposal.
the consensus there no reason introduce more syntactical sugar necessary, calling promise.all
not of difference.
you can check out discussions in issue 8 or issue 29.
finally, proposals mightier weapons (parallelism) still under way. check out async iteration, async generators , observables. there might use await*
keyword better simple arrays of promises.
the async
/await
proposal minimal , introduces necessary primitives. there no bikeshedding possible extensions, should discussed separately.
Comments
Post a Comment