How check if a function is async in Node.js

2 Answers

0 votes
async function func() {
 
}
 
const isAsync = func.constructor.name === "AsyncFunction";
 
console.log(isAsync);
  
   
   
   
    
/*
run:
    
true
    
*/

 



answered May 26, 2022 by avibootz
0 votes
const func = async (x, y) => {
  
};
  
const isAsync = func.constructor.name === "AsyncFunction";
  
console.log(isAsync);
   
    
    
    
     
/*
run:
     
true
     
*/

 



answered May 26, 2022 by avibootz

Related questions

1 answer 228 views
2 answers 163 views
2 answers 254 views
1 answer 153 views
1 answer 136 views
1 answer 120 views
1 answer 132 views
...