19.1.7 • Published 5 months ago

@wasm-fmt/clang-format v19.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Test

Install

npm

npm install @wasm-fmt/clang-format

jsr.io

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:

  1. A preset: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
  2. A YAML/JSON string representing the style options.
  3. the string content of a .clang-format file.

See Clang-Format Style Options for more information.

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 scripts/build.sh.
19.1.7

5 months ago

19.1.6

6 months ago

19.1.5

7 months ago

19.1.4

7 months ago

19.1.3

8 months ago

19.1.2

9 months ago

19.1.0

9 months ago

19.1.1

9 months ago

18.1.8

11 months ago

18.1.7

11 months ago

18.1.6

11 months ago

18.1.5

11 months ago

18.1.4

11 months ago

18.1.3

11 months ago

18.1.2

11 months ago

18.1.1

11 months ago

18.1.0

11 months ago

17.0.5

12 months ago

17.0.6

11 months ago

17.0.3

12 months ago

17.0.2

12 months ago

17.0.4

12 months ago

17.0.1

12 months ago

16.0.6

12 months ago

0.2.10

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago