Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you know if a function is asynchronous or synchronous in node.js?

Is there any way to know if a function is asynchronous or synchronous in node.js ? Thanks in advance.

like image 638
Koushik Das Avatar asked Feb 17 '26 06:02

Koushik Das


1 Answers

There's no programmatic way to tell.

The reliable way is to read the documentation.

You can also try to infer it from the function accepting a callback (but that isn't reliable, see Array.prototype.forEach for an example of a synchronous function that accepts a callback).

like image 96
Quentin Avatar answered Feb 18 '26 21:02

Quentin