Is it possible to create some enum
in C++ code of Node.js addon and then expose this type to js code? I found that native enum types exist in js, but there's no information about their implementation in v8 engine.
Note that in the example given by Kevin you need to create an instance of Local<Object>
before using it so make sure you call Object::New()
.
Local<Object> obj = Object::New();
const char* k = "HEADERS_RECEIVED";
int v = 1;
obj->Set(v8::String::NewSymbol(k), v8::Int32::New(v), ReadOnly); // Use PropertyAttribute ReadOnly so that value won't be changed by javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With