0.1.1 • Published 10 months ago

clang.js v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
10 months ago

Overview

npm.io

This repo is extending the great work from Ben Smith published in his CppCon 2019 WebAssembly talk. The WebAssembly binaries are copied from Ben's fork of llvm-project.

Installation

# NPM
npm install clang.js

# Yarn
yarn add clang.js

Usage

import { init, run } from 'clang.js';

async function main() {
  await init({
    // The path to the wasm resources
    path: 'https://cdn.jsdelivr.net/npm/clang.js/dist',
  });

  const code = `
    #include <iostream>
    using namespace std;

    int fib(int n) {
      if (n < 2) return n;
      return fib(n-1) + fib(n-2);
    }

    int main() {
      cout << "fib(10) = " << fib(10) << endl;
    }`;
  
  run(code);
}

main();

License

Apache-2.0

0.1.1

10 months ago

0.1.0

10 months ago