Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/wasm-fmt/yamlfmt
- Owner: wasm-fmt
- License: mit
- Created: 2024-05-20T17:13:50.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-11T22:57:17.000Z (3 days ago)
- Last Synced: 2024-11-11T23:33:59.037Z (3 days ago)
- Language: Rust
- Homepage:
- Size: 129 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)