# wasmexplorer-wasm-compiler

Compile `.c/++` files to `.wasm` format using [WasmExplorer](https://mbebenita.github.io/WasmExplorer/) service by [@mbebenita](https://github.com/mbebenita).

## Usage
```js
const compile = require('wasmexplorer-wasm-compiler');
// compile(srcFilepath, dstFilepath, compilerOptions = {});
```

## Arguments

1. `srcFilepath`: Absolute path to source file.
2. `dstFilepath`: Absolute path to destination/compiled file.
3. `compilerOptions`: Options to pass to compiler. See the [table](#compiler-options) below.

### Compiler Options

| Option              | Type   | Default | Description                                                                                |
| ------------------- | ------ | ------- | ------------------------------------------------------------------------------------------ |
| `language`          | string | C99     | The language to use. One of [C89, C99, C++98, C++11, C++14, C++1z]                         |
| `optimisationLevel` | string | s       | Optimisation level to apply. One of [0, 1, 2, 3, 4, s]                                     |
| `clean`             | bool   | false   | Generate clean WAST                                                                        |
| `fastMath`          | bool   | false   | Approximate floating point calculations for faster execution (may yield incorrect results) |
| `noInline`          | bool   | false   | Do not expand functions inline.                                                            |
| `noRTTI`            | bool   | false   | Do not generate runtime type information.                                                  |
| `noExceptions`      | bool   | false   | Disable exception handling. `try/catch` will raise errors.                                 |
