How to get a JavaScript number as a string using Node-API
I’m building a Node.js addon using Node-API.
I’m building a Node.js addon using Node-API.
Expectation I want to to implement using a native NodeJS module that works like the javascript module below class C1{ make(){return new C2()} } class C2{} module.exports({C1, C2}) Approach My attempt was, (among some other failed attempts) // so.cpp #include <napi.h> class C1: public Napi::ObjectWrap<C1> { public: C1(const Napi::CallbackInfo &info); static void Initialize(Napi::Env& env, Napi::Object& … Read more
This is just an example of the problem.
I am building a C++ addon for NodeJS and I want to stream data asynchronously from C++ to Node. I have found this article, https://nodeaddons.com/streaming-data-into-a-node-js-c-addon/, however; I want to use the N-API instead of NAN.
I have a custom API (closed source for now), built in pure C. This API is the client side of a communication protocol (think network-based database queries). I have successfully used node-gyp
to compile the C code wrappers so that the NAPI addon addon.node
can function in JavaScript by calling the C. I have also written a .d.ts
file, so that this addon can work from TypeScript. I have no issue with both of these use cases; ie, doing a tsc index.ts && nodejs index.js
will compile and run the imported/required addon without a hitch, and the client-side operations of my C API happen without a hitch. I have made this addon into a private npm package, and have been using it in small TypeScript projects by installing it as a node_modules
dependency without any issue.