Created
April 23, 2022 10:54
-
-
Save yoshoku/b320fd899dcf14b0ca1707e92e7775d3 to your computer and use it in GitHub Desktop.
console.log with node-addon-api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <napi.h> | |
class Foo : public Napi::ObjectWrap<Foo> { | |
public: | |
// ... | |
Napi::Value foo(const Napi::CallbackInfo& info) { | |
Napi::Env env = info.Env(); | |
Napi::Function consoleLog = env.Global().Get("console").As<Napi::Object>().Get("log").As<Napi::Function>(); | |
consoleLog.Call({ Napi::String::New(env, "Hello, World.") }); | |
// ... | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment