process.binding connects the JavaScript side of Node.js to the C ++ side of Node.js. The C ++ side of node.js is where most of the internal work of everything that the node does is implemented. So most of your code ultimately relies on C ++ code. Node.js uses the power of C ++.
Here is an example:
const crypto=require("crypto") const start=Date.now() crypto.pbkdf2("a", "b", 100000,512,sha512,()=>{ console.log("1":Date.now()-start) })
Crypto is a built-in module in Node.js for hashing and saving passwords. This is how we implement this in Node.js, but the actual hashing process happens on the C ++ side of the node.js.
process.binding("crypto") will send this process to the src exporters directory, where the C ++ world of Node.js. is located In this part, Node.js V8 will convert the node.js values โโthat we put into our various programs, such as a boolean, or function, or object, and translate them into their C ++ equivalents.
After the Javascript code has been translated into C ++, libuv will happen and it will do all the heavy calculations to execute the above code on the C ++ side outside the loop of events in the thread pool.
Yilmaz Jun 10 '19 at 7:48 2019-06-10 07:48
source share