44 lines
792 B
Plaintext
Raw Normal View History

An ``++async++`` function always wraps the return value in a ``++Promise++``. Using ``++return await++`` is not required and comes at an extra performance cost.
However, you might wish to keep it as it preserves the function call in the stack trace in case an error is thrown asynchronously.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
async function foo() {
// ...
}
async function bar() {
// ...
return await foo(); // Noncompliant
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
async function foo() {
// ...
}
async function bar() {
// ...
return foo();
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
endif::env-github,rspecator-view[]