Closed prodypanda closed 4 months ago
async function getUserByName(name: string) {
// find() returns a Promise<User | null >.
return db.users.find({ userName: name })
}
// OR:
async function getUserByName(name: string) {
// If we must await the return-value in this function
// it's better to do it this way. This is more performant:
const user = await db.users.find({ userName: name })
return user;
Description
Returning an awaited value (like with
return await f()
) has two problems: - It queues an extra microtask, blocking the callstack untilreturn
is executed.Occurrences
There is 1 occurrence of this issue in the repository.
See all occurrences on DeepSource → app.deepsource.com/gh/prodypanda/MarkEnti/issue/JS-0111/occurrences/