Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wasm-fmt/yamlfmt

A WASM Based YAML Formatter
https://github.com/wasm-fmt/yamlfmt

Last synced: 3 days ago
JSON representation

A WASM Based YAML Formatter

Awesome Lists containing this project

README

        

[![Test](https://github.com/wasm-fmt/yamlfmt/actions/workflows/test.yml/badge.svg)](https://github.com/wasm-fmt/yamlfmt/actions/workflows/test.yml)

# Install

[![npm](https://img.shields.io/npm/v/@wasm-fmt/yamlfmt?color=cb171e)](https://www.npmjs.com/package/@wasm-fmt/yamlfmt)

```bash
npm install @wasm-fmt/yamlfmt
```

[![jsr.io](https://jsr.io/badges/@fmt/yamlfmt?color=cb171e)](https://jsr.io/@fmt/yamlfmt)

```bash
npx jsr add @fmt/yamlfmt
```

# Usage

```javascript
import init, { format } from "@wasm-fmt/yamlfmt";

await init();

const input = "- a\n- b\n";

const formatted = format(input, "sample.yaml");
console.log(formatted);
```

For Vite users:

Add `"@wasm-fmt/yamlfmt"` to `optimizeDeps.exclude` in your vite config:

```JSON
{
"optimizeDeps": {
"exclude": ["@wasm-fmt/yamlfmt"]
}
}
```

If you cannot change the vite config, you can use another import entry

```JavaScript
import init, { format } from "@wasm-fmt/yamlfmt/vite";

// ...
```

# Credits

Thanks to:
- [pretty_yaml](https://github.com/g-plane/pretty_yaml)