JSPM

  • Created
  • Published
  • Downloads 580
  • Score
    100M100P100Q112973F
  • License MIT

A wasm based clang-format

Package Exports

  • @wasm-fmt/clang-format
  • @wasm-fmt/clang-format/package.json
  • @wasm-fmt/clang-format/vite

Readme

Test npm

Install

npm install @wasm-fmt/clang-format

Usage

import init, { format } from '@wasm-fmt/clang-format';

await init();

const source = `
#include <iostream>
using namespace std;
auto main() -> int{
std::cout << "Hello World!" << std::endl;
return 0;}
`;

const formatted = format(
    source,
    "main.cc",
    JSON.stringify({
        BasedOnStyle: "Chromium",
        IndentWidth: 4,
        ColumnLimit: 80,
    })
);

console.log(formatted);

Build from source

  1. Install LLVM and Clang (version 18 or later).
  2. Install CMake (version 3.27 or later).
  3. Install Ninja (version 1.11 or later).
  4. Clone this repository.
  5. Run scrips/build.sh.