Skip to content

Instantly share code, notes, and snippets.

@Hermitter
Created December 19, 2018 17:06
Show Gist options
  • Save Hermitter/2fc71d879dfede1ad5cff8e341273dd1 to your computer and use it in GitHub Desktop.
Save Hermitter/2fc71d879dfede1ad5cff8e341273dd1 to your computer and use it in GitHub Desktop.
simple code snippets to help me with nan.h in node.js addons.
// grab array
v8::Local<v8::Array> jsArray = v8::Local<v8::Array>::Cast(info[0]);
// array length
int arraySize = jsArray->Length();
// grab first array element & converto to proper type
int indexOne = jsArray->Get(0)->Int32Value();
// return element
info.GetReturnValue().Set(indexOne);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment