Skip to main content

latest
Works with
JSR Score
23%
Published
2 weeks ago (0.2.8)

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.

Add Package

deno add @mst-mkt/clang-fmt

Import symbol

import * as mod from "@mst-mkt/clang-fmt";

Add Package

npx jsr add @mst-mkt/clang-fmt

Import symbol

import * as mod from "@mst-mkt/clang-fmt";

Add Package

yarn dlx jsr add @mst-mkt/clang-fmt

Import symbol

import * as mod from "@mst-mkt/clang-fmt";

Add Package

pnpm dlx jsr add @mst-mkt/clang-fmt

Import symbol

import * as mod from "@mst-mkt/clang-fmt";

Add Package

bunx jsr add @mst-mkt/clang-fmt

Import symbol

import * as mod from "@mst-mkt/clang-fmt";