Questions tagged [node.js-addon]

Native C++ addons for node.js

This tag is for node.js native addons: https://nodejs.org/api/addons.html

291 questions
5
votes
4 answers

Shortest way (one-liner) to get a default argument out of a v8 function?

It's been a long time since I've used C++, and even longer since I wrapped my head around hard types. I'm simply looking for a working one liner to do get an argument from v8, or a default value when an argument wasn't…
Caleb Gray
  • 3,040
  • 2
  • 21
  • 32
4
votes
1 answer

How do I save a callback for later with node-addon-api?

I want my C library to be able to call a JS function multiple times. I got it to work using Nan but am having trouble converting it to N-API/node-addon-api. How do I save a JS callback function and call it later from C? Here's what I have using…
iffy
  • 719
  • 1
  • 4
  • 20
4
votes
1 answer

how to deliver c++ array to node.js using v8 native addon

I implemented a c++ addon module that creates some buffer using unsigned char(uint8_t) memory and delivers it to node.js. ---- c++ addon.cpp ---- void get_frame_buffer(const FunctionCallbackInfo& args){ Isolate* isolate =…
map.sosa
  • 41
  • 2
4
votes
1 answer

How to read/write data to ArrayBuffer from C++ Node.js addon?

In short, I have an addon that completes an operation which results in a uint8_t array. I need to convert this array and its contents to an ArrayBuffer, and return that. Conversely, the addon can also accept an ArrayBuffer as input, and I need to…
S. Vaughn
  • 86
  • 1
  • 7
4
votes
2 answers

Node Addons (C++) in Electron

I'm trying to integrate C++ with HTML using Electron and Node JS.But I'm confused by the NODE_MODULE_VERSION. I have a binding.gyp like examples. { "targets": [ { "target_name": "addon", "sources": [ "src/hello.cc" ], …
Zhi Zhang
  • 101
  • 2
  • 6
4
votes
1 answer

Integrate C++ on webOS project

I'm developing a project for webOS 3.0 and I want to know if it's possible to integrate a C++ lib binary on a webOS aplication. I am tying to use nodejs addons and require the addon.node file into a JSservice like a module, but, according to this…
4
votes
1 answer

Return a Nan::ObjectWrap from another Nan::ObjectWrap

I have two subclasses of Nan::ObjectWrap class Zyre: public Nan::ObjectWrap {...} class ZyreEvent: public Nan::ObjectWrap {...} How can I return a ZyreEvent javascript object from a method in Zyre? I have the following method, in which I create a…
Damiaan Dufaux
  • 4,427
  • 1
  • 22
  • 33
4
votes
1 answer

NodeJS Addon calling Javascript callback from inside NAN AsyncWorker::Execute

I would like to call a nodejs callback from within my asynchronous addon function. I have seen the synchronous example (here) and I am using a wonderful asynchronous example (here) as a starting base. However, when I try to execute a callback that…
EToreo
  • 2,936
  • 4
  • 30
  • 36
4
votes
5 answers

C++ node.js module. cout not working?

Hi I am a noob in C++ trying to modify an existing native node module. I am trying to add couts inside the module to print info I think is useful for me. NAN_METHOD(Context2d::SetFillRule){ Context2d *context =…
cs04iz1
  • 1,737
  • 1
  • 17
  • 30
4
votes
2 answers

libuv thread communication

I have a c++ lib, client application use this lib to query data from server. This lib create a seperate thread to communicate with server, query result will be passed as parameters in callback function. Now i want to wrap this c++ lib to nodejs…
forrest
  • 94
  • 5
4
votes
1 answer

C++ node.js Addons - Explanation of parameters in Init()

Can someone explain the difference between the one-argument form and the two-argument form of Init when creating a c++ node.js addon? void Init(Local exports) {} void Init(Local exports, Local module) {}
nick
  • 43
  • 3
4
votes
0 answers

Is it possible to compose Maybe operations with the new version of Nan?

Nan 2.0, for compatibility with Node 4.0, introduced Maybe and MaybeLocal types, and several functions that return them. However, most of them do not seem to accept Maybe objects, and in several cases I would want to compose those methods. For…
murgatroid99
  • 19,007
  • 10
  • 60
  • 95
4
votes
1 answer

V8 Multithreaded function

I'm writing a Node plugin and I'm having problems trying to call a V8 function object from a C++ worker thread. My plugin basically starts a C++ std::thread and enters a wait loop using WaitForSingleOject(), this is triggered by a different C++ app…
TheZapper
  • 122
  • 2
  • 10
4
votes
1 answer

Node.js and C/C++ integration: how to properly implement callbacks?

I am trying to implement a C++ extension to be integrated with node.js. This extension will internally invoke some blocking calls, so it needs to provide a non-blocking interface to the node.js world. As specified in…
Luis Crespo
  • 738
  • 7
  • 20
4
votes
1 answer

Node C++ Addon - How do I access a Typed Array (Float32Array) when it's been passed as an argument?

I'd like to make use of the V8 Float32Array data structure. How can I initialise it? I'd also be interested in direct memory access to the data. How could that be done?
user1315172
  • 147
  • 3
  • 9
1 2
3
19 20