@wasm-fmt/clang-format v19.1.7
Install
npm install @wasm-fmt/clang-format
npx jsr add @fmt/clang-format
Usage
CLI
This repository contains two executable files, namely clang-format and git-clang-format. For more information, please refer to https://clang.llvm.org/docs/ClangFormat.html
API
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;}
`;
// JSON representation of Clang-Format Style Options
const config = JSON.stringify({
BasedOnStyle: "Chromium",
IndentWidth: 4,
ColumnLimit: 80,
});
// or YAML representation of Clang-Format Style Options which is used in `.clang-format` file
const config2 = `---
BasedOnStyle: Chromium
IndentWidth: 4
ColumnLimit: 80
...
`;
// or the preset name
const config3 = "Chromium";
const formatted = format(
source,
"main.cc",
config,
);
console.log(formatted);
The third argument of format
is a Clang-Format Style Options, which can be one of the following:
- A preset: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
- A YAML/JSON string representing the style options.
- the string content of a
.clang-format
file.
See Clang-Format Style Options for more information.
Build from source
5 months ago
6 months ago
7 months ago
7 months ago
8 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago