How do you create custom asynchronous functions in node.js?

后端 未结 2 1070
清歌不尽
清歌不尽 2020-11-27 21:56

I was unsure how node.js was able to realize what functions where async and which were not and how to create a custom async function.

Say I wanted to create a custom

2条回答
  •  Happy的楠姐
    2020-11-27 22:21

    Only native functions (with access to the event loop) are asynchronous. You would need to call one of them to get asynchronity for your callback. See What is a simple example of an asynchronous javascript function?.

    If you aren't using any, there's hardly a reason to make your function asynchronous.

提交回复
热议问题