

inline-cpp
Inline C++ with Node.js
Installation
npm install --save inline-cpp
or
npm install -g inline-cpp
Usage
const compile = require('inline-cpp');
const Hello = compile `
String func(const CallbackInfo& info) {
return String::New(info.Env(), "Hello");
}
`
const World = compile `
String func(const CallbackInfo& info) {
return String::New(info.Env(), "World!");
}
`
console.log(Hello(), World())
Now run it:
➜ node test.js
Hello World!
The first time you run the script, it takes longer time to execute.
For each inline block of code, a native module will be generated, compiled with node-gyp and loaded dynamically.
The next time you run the script, it will reuse previous build results (unless you change the inline C++ code). The build results are cached.
Disclaimer
This is only a prototype. I created this to check the geneal concept.
You're welcome to contribute - here are some ideas: