// this is an example of a C++ module running on Node.js
// the real power comes through TypeScript bindings though,
// so be sure to check out the rest of the project at
// https://github.com/TheLartians/modern-wasm-starter
const modern_wasm_starter = require("modern-wasm-starter");
// `withGreeter()` will run the callback asynchronously in a memory scope
// and return the result in a `Promise`
modern_wasm_starter.withGreeter(greeterModule => {
// construct a new C++ `Greeter` instance
const greeter = new greeterModule.Greeter("Wasm");
// call a member function and return the value
return greeter.greet(greeterModule.LanguageCode.EN);
// any created C++ objects will be destroyed after the function exits,
// unless they are persisted
});
Created from: https://npm.runkit.com/modern-wasm-starter