apihlaja / node-irsdk

iRacing SDK implementation for Node.js.
https://apihlaja.github.io/node-irsdk
MIT License
101 stars 55 forks source link

Port to N-API? #33

Open apihlaja opened 6 years ago

apihlaja commented 6 years ago

It seems Node.js have new API for native addons, should take a look if it makes sense to port: https://github.com/nodejs/node-addon-api

apihlaja commented 6 years ago

N-API is experimental as of Node.js v9: https://nodejs.org/dist/v9.3.0/docs/api/addons.html#addons_n_api

As far as I understood, current nan based C++ code should continue to work. So there is no immediate need to port to new API, but porting might make it easier to improve performance. Not like I'd have noticed any performance issues but obviously you dont want to waste CPU cycles when driving.

The current version of node-irsdk runs in main event loop, and polls memory mapped file from javascript. That's something I would like to get rid of ie. C++ addon should be event emitter itself and do polling in C++ land. It seems running outside of main event loop will be a bit easier with N-API: https://nodejs.org/dist/v9.3.0/docs/api/n-api.html#n_api_custom_asynchronous_operations

twk-b commented 4 years ago

Error: The module '\?\C:\Users\twk-b\itwkracing\node\node_modules\node-irsdk\build\Release\IrSdkNodeBindings.node'
was compiled against a different Node.js version using NODE_MODULE_VERSION 64. This version of Node.js requires NODE_MODULE_VERSION 72. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install).

this is on upgrade to node-12 from node-12. npm rebuild, rmrf package-lock.json node_modules npm install also fails.