I wonder if it is possible to use the "os" module internally in native module, without passing it over as a param from javascript.
It's one of the core nodejs/electron modules so I assume it should be available in native module internally some way or another.
Expanding on my comment:
As far as I know, none of node's
"os"
module C++ code is exported for use by other C++ code.Executing JS from C++ is possible, but far from efficient. (See https://stackoverflow.com/a/11387695/1218408 for an example of how to do it.)
Most of node's
"os"
module is fairly simple, and you're probably better off re-implementing whatever you need. The source for it is here: https://github.com/nodejs/node/blob/master/src/node_os.ccAnother possibility is to call your C++ functions with the result of whatever JS function you need. For example, maybe
myFunction(os.loadavg(), "hello")
. Simple but also not super efficient.