async function sleep(msecs){
if (!somebodyAwaitsMe()) // that's the unknown
throw ("call me with await");
return new Promise(resolve => setTimeout(resolve, ms));
}
await sleep(5000); // correct
sleep(5000); // forgot await, returns immediately,
I want to know, inside an async function, if it has been called with await or not, is that possible?
The code exemplifies a possible situation to help detect mistakes but it may be useful in other situations where a function may be invoked by design, with or without await.