fix: remove unnecessary return await statements
There's no need to use await while returning an asynchronous function in JavaScript.
Previous:
async function example() {
return await someAsynchronousFunction();
}
New:
async function example() {
return someAsynchronousFunction();
}
Both code examples achieve the same result, but the second one is more concise and arguably clearer.
I noticed that the recent changes were approved but have not been merged yet. Could you please merge them when you have a moment?
For that matter, the async declaration also becomes redundant because await keyword is not used in the function body.
// same as other versions
function example() {
return someAsynchronousFunction();
}
Though, an argument can be made that the declaration is useful to clearly see that the function returns a promise.
For that matter, the
asyncdeclaration also becomes redundant becauseawaitkeyword is not used in the function body.// same as other versions function example() { return someAsynchronousFunction(); }Though, an argument can be made that the declaration is useful to clearly see that the function returns a promise.
In a simple example, we use a wrapper function that returns a promise. Making it asynchronous is not necessary and should be considered. For a much simpler implementation, it's clear that using someAsynchronousFunction directly makes more sense than wrapping it with another function. Also, if it's just for naming reasons, it's fine for the function to not use any async/await statements.
I agree with you @mohit4bug but keeping it in codebase does not affect the logic. However, we will consider this refcator PR in the future while we revamp the code and address some logical as well as compatibility issues. Thank you! Closing for now