如何同步确定JavaScript的承诺状态?

Kaivosukeltajajokeyrhyme提出了一个问题:How can I synchronously determine a JavaScript Promise's state?,或许与您遇到的问题类似。

回答者Benjamin Gruenbaum给出了该问题的处理方式:

No such synchronous inspection API exists for native JavaScript promises. It is impossible to do this with native promises. The specification does not specify such a method.

Userland libraries can do this, and if you're targeting a specific engine (like v8) and have access to platform code (that is, you can write code in core) then you can use specific tools (like private symbols) to achieve this. That's super specific though and not in userland.

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:custom-guider
下一篇:什么是双大括号的目的反应。JS '的JSX语法?

公众号

欢迎 JavaScript 爱好者