Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wasm-fmt/zig_fmt
A WASM Based Zig Formatter
https://github.com/wasm-fmt/zig_fmt
formatter formatting wasm webassembly zig
Last synced: 4 months ago
JSON representation
A WASM Based Zig Formatter
- Host: GitHub
- URL: https://github.com/wasm-fmt/zig_fmt
- Owner: wasm-fmt
- License: mit
- Created: 2023-09-01T05:08:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-15T19:08:03.000Z (4 months ago)
- Last Synced: 2024-10-17T03:56:21.481Z (4 months ago)
- Topics: formatter, formatting, wasm, webassembly, zig
- Language: Zig
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Test](https://github.com/wasm-fmt/zig_fmt/actions/workflows/test.yml/badge.svg)](https://github.com/wasm-fmt/zig_fmt/actions/workflows/test.yml)
[![npm](https://img.shields.io/npm/v/@wasm-fmt/zig_fmt)](https://www.npmjs.com/package/@wasm-fmt/zig_fmt)# Install
```bash
npm install @wasm-fmt/zig_fmt
```# Usage
```javascript
import init, { format } from "@wasm-fmt/zig_fmt";await init();
const input = `
const std = @import("std");pub fn main() !void
{
const stdout = std.io.getStdOut().writer();
var i: usize = 1;
while (i <= 16) : (i += 1)
{
if (i % 15 == 0)
{
try stdout.writeAll("ZiggZagg\\n");
} else
if (i % 3 == 0)
{
try stdout.writeAll("Zigg\\n");
} else
if (i % 5 == 0)
{
try stdout.writeAll("Zagg\\n");
}
else
{
try stdout.print("{d}\\n", .{i});
}
}
}
`;const formatted = format(input);
console.log(formatted);
```For Vite users:
```JavaScript
import init, { format } from "@wasm-fmt/zig_fmt/vite";// ...
```