Questions tagged [node-nan]
10 questions
3
votes
1 answer
How to use Maybe version of v8::String::NewFromUtf8?
I'm trying to build a native node module against Node 12 and am getting errors such as:
warning: ‘static v8::Local v8::String::NewFromUtf8(v8::Isolate*, const char*, v8::String::NewStringType, int)’ is deprecated: Use maybe version…

logidelic
- 1,525
- 15
- 42
2
votes
1 answer
how to implement node-nan callback using node-addon-api
Until now I've only implemented synchronous node-addon-api methods, i.e., a JavaScript function makes a call, work is done, and the addon returns. I have big gaps in knowledge when it comes to the inner workings of v8, libuv, and node, so please…

bmacnaughton
- 4,950
- 3
- 27
- 36
2
votes
2 answers
How to check in an node.js C++ addon, if a promise is resolved
The Task:
I call a callback from C++ that return a v8::Promise (so an async function).
Now I want to find out if the promise was resolved.
For this example here, I want to check from JS if the promise is resolved.
But "just beeing informed in the…

GerritP
- 33
- 4
2
votes
1 answer
Handling JavaScript objects in a C++ node nan addon
My code is passing a JavaScript object to a function implemented in C++. The C++ code needs to validate the type of each property and supply a default value if either the property is missing or the type is wrong.
The following code seems to work…

bmacnaughton
- 4,950
- 3
- 27
- 36
1
vote
1 answer
How to check a napi_value of type napi_number is an integer or decimal by using node.js N-API function,
How to check a given napi_value of type napi_number is an integer or decimal (a number with fractional value) by using node.js native N-API function .
Look like there is no isInt() or isDouble() equivalent function in N-API (we don’t want to use V8…

Satyan
- 1,346
- 8
- 15
1
vote
1 answer
Node addon compilation error
I am new to creating c++ addons for node.
I've instaled windows-build-tools and after running node-gyp build I've encountered a strange problem.
I tryed to do some research before asking this question but it seams there is no clear answer.
I've…

Maciej Kozieja
- 1,812
- 1
- 13
- 32
1
vote
0 answers
how does two argument constructor get called in nodejs addon?
I'm new to nodejs addons and am learning on the fly working with existing code. I have a situation where I don't understand how a specific C++ constructor is being called nor how the value of an argument is being set.
There are two pure C++…

bmacnaughton
- 4,950
- 3
- 27
- 36
0
votes
0 answers
Should I check NODE_MODULE_VERSION or V8_MAJOR_VERSION/V8_MINOR_VERSION?
I'm working on a native module for Node.js and I see that there's two ways to check which V8 version it's being run on:
#if (V8_MAJOR_VERSION < 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERSION < 4))
or
#if defined NODE_MODULE_VERSION &&…

Boris Verkhovskiy
- 14,854
- 11
- 100
- 103
0
votes
1 answer
NODE N-API When using functions from addon blocks the main process node js?
Implemented a wrapper for the function using N-API. It works, but the problem is that when it works the main thread of the node does not work? How can I rewrite this function so that it does not block the main thread? What do I need to use async,…

saper639
- 11
- 4
0
votes
1 answer
TypeError: [c++ addon class] is not a constructor
TypeError: m.Default is not a constructor is the error I'm getting when I try to make a JavaScript class by using NAN.
Here's what I'm doing:
//AudioDeviceController.h
#pragma once
#include
class Default : public Nan::ObjectWrap
{
public:
…

Jack
- 520
- 2
- 16