本文介绍了为什么等待*从异步/等待提议中删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 似乎唯一记录的地方是此问题主题和实际规范。但是,删除的原因并没有张贴在我能找到的任何地方。The only place it seems to be documented is this issue thread and the actual specification. However, the reasoning for the removal isn't posted anywhere I could find.新建议的方式似乎是 await Promise.all() ,但我很好奇为什么等待* 被删除。The new recommended way seems to be await Promise.all(), but I'm curious as to why await* was removed.推荐答案那么,自动删除之前的自述文件的最新修订版已经提到该段落中的所有内容:Well, the last revision of the readme before it was removed already mentions everything in that paragraph: await * and parallelism 在生成器中,可以使用 yield 和 yield * 。在async 函数中,只允许等待。直接类比 yield * 在异步函数中没有意义,因为它需要反复等待内部操作,但不知道是什么的值传递到每个await(对于 yield * ,它只传递未定义的,因为迭代器不接受传入的值)。 await* and parallelism In generators, both yield and yield* can be used. In async functions, only await is allowed. The direct analogoue of yield* does not make sense in async functions because it would need to repeatedly await the inner operation, but does not know what value to pass into each await (for yield*, it just passes in undefined because iterators do not accept incoming values).有人建议语法可以重用于不同的语义 - 糖为 Promise.all 。这将接受一个Promises数组的值,并且(异步地)返回promises返回的值的数组。预计这将是最常见的与Promise相关的操作之一,在该提案的核心可用之后还没有语法 sugar。It has been suggested that the syntax could be reused for different semantics - sugar for Promise.all. This would accept a value that is an array of Promises, and would (asynchronously) return an array of values returned by the promises. This is expected to be one of the most common Promise-related oprerations that would not yet have syntax sugar after the core of this proposal is available.所以它与 yield * 没有直接的比喻,正如人们所料,没有意义,这只是一个建议,但在规范提案中从未真正包含。So it's no direct analogue to yield* as one might expect, it doesn't really make sense, it was only a suggestion but never really included in the spec proposal.一致认为没有理由引入超过必要的语法糖,调用 Promise.all 并没有什么区别。The consensus was that there is no reason to introduce more syntactical sugar than necessary, calling Promise.all is not much of a difference.您可以在第8期或 issue 29 。最后,关于更强大武器(并行性)的建议仍在进行中。查看异步迭代,异步生成器和 observables 。可能有一些可以使用等待* 关键字比简单的承诺数组更好。Finally, proposals for mightier weapons (parallelism) are still under way. Check out async iteration, async generators and observables. There might be some that could use an await* keyword much better than for simple arrays of promises. async / 等待提案最小,只介绍必要的原语。关于可能的扩展没有自行决定,应该单独讨论。The async/await proposal is minimal and only introduces the necessary primitives. There is no bikeshedding about possible extensions, which should be discussed separately. 这篇关于为什么等待*从异步/等待提议中删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 05:03