Want to create a custom function in nodejs that runs asynchronously. Read about libuv library and async npm library in nodejs. Is libuv used only for asynchronous I/O functions? Which one I need to use. Does async library uses libuv internally when creating asynchronous task? what is difference between the two libraries
Asked
Active
Viewed 74 times
0
-
1You should return a [`promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) or write an [`async function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function). – AskYous Mar 13 '18 at 23:29
-
thx do I need to write a custom ibrary using libuv and link it to nodejs? Is there any wrapper library over libuv exists that I can use in nodejs to create custom asynchronous function and set a callback? – Arav Mar 13 '18 at 23:52
-
What are you trying to solve with your function? What is your use case? – rtn Mar 14 '18 at 00:32
-
I need to write c++ code for achieving asynchronous execution? java provide threads for asynchronous execution. how nodejs is superior to java in terms of asynchronous execution as I need to create c++ library each time – Arav Mar 14 '18 at 00:48
-
1Have you created any node.js code yet? Can you show us some node.js code that your trying to run asynchronously? Node.Js is all about asynchrounous code you don't need libuv since its already used under the hood. Can you show us the code you have tried? – Usman Mutawakil Mar 14 '18 at 06:07
-
1_"I need to write c++ code for achieving asynchronous execution?"_ -- No you don't. Asynchronicity is one of the core parts of the Javascript language. Unless you confuse the concepts ["parallel", "concurrent, and "asynchronous"](https://stackoverflow.com/q/4844637/544779)? In any case, node.js supports all of them. It is not clear from your question what you actually want, why you don't just write Javascript. Why do you want to write a native module for node.js instead of just Javascript? What do you want to achieve? Given your questions it's doubtful that you need what you ask for. – Mörre Mar 14 '18 at 08:50