Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Created August 12, 2015 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghaiklor/259372c5049dbc52b947 to your computer and use it in GitHub Desktop.
Save ghaiklor/259372c5049dbc52b947 to your computer and use it in GitHub Desktop.
DefineJavaScript method in NodeJS that loading all the JS modules
void DefineJavaScript(Environment* env, Handle<Object> target) {
HandleScope scope(env->isolate());
for (int i = 0; natives[i].name; i++) {
if (natives[i].source != node_native) {
Local<String> name = String::NewFromUtf8(env->isolate(), natives[i].name);
Handle<String> source = String::NewFromUtf8(env->isolate(), natives[i].source, String::kNormalString, natives[i].source_len);
target->Set(name, source);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment