node-addon-examples icon indicating copy to clipboard operation
node-addon-examples copied to clipboard

Nan conversion of external type

Open imrehg opened this issue 6 years ago • 2 comments

Have a piece of code, that works on node <12, but will need to be converted to for node 12.

return static_cast<ext2_filsys>(
  info[0]->ToObject().As<v8::External>()->Value()
);

I couldn't see any examples for v8::External in conversion (i.e. I'm guessing using it with Nan::To<v8::Object>?)

What would be an example of using such v8::External cases?

imrehg avatar May 02 '19 14:05 imrehg

Resolved it with this form, but feels like I might be mixing stuff here quote a bit.

return static_cast<ext2_filsys>(
   Nan::To<v8::Object>(info[0]).ToLocalChecked().As<v8::External>()->Value()
);

imrehg avatar May 02 '19 17:05 imrehg

@imrehg we are mostly maintaining the napi/node-addon-api examples. Sounds like you may have already answered your own question anyway.

mhdawson avatar May 09 '19 13:05 mhdawson