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 227 views
2 answers 161 views
2 answers 250 views
1 answer 150 views
1 answer 134 views
1 answer 118 views
1 answer 127 views
...