@emscriptenjs/emscriptenjs
v1.1.30
Published
This is a WIP repository for an Emscriptenjs npm package with the core functionalities.
Downloads
4
Readme
emscriptenjs
This is a WIP repository for an Emscriptenjs npm package with the core functionalities.
Disclaimer: Unstable project, do not use in unrelated projects
Usage
- Instantiate an
Emscriptenjsobject - Initiate Emscriptenjs with
init(codeString)method giving the code as a parameter - Subscribe to output events (
compilationStdout,compilationStderr,executionStdout,executionStderr) - Compile code with
compile()method - Execute code with
execute()method
Usage example
const emscriptenjs = new Emscriptenjs();
await emscriptenjs.init(codeString);
// Listen for compilation stdout events
emscriptenjs.on('compilationStdout', (data) => {
// ... your code here
});
// Listen for compilation stderr events
emscriptenjs.on('compilationStderr', (data) => {
// ... your code here
});
const result = await emscriptenjs.compile();
if (result.returncode === 0) {
// ... compilation succeded
// Listen for execution stdout events
emscriptenjs.on('executionStdout', (data) => {
// ... your code here
});
// Listen for execution stderr events
emscriptenjs.on('executionStderr', (data) => {
// ... your code here
});
emscriptenjs.execute();
} else {
// ... compilation failed
}