@wasm-fmt/taplo_fmt
v0.2.4
Published
A WASM based TOML Formatter
Readme
Install
npm install @wasm-fmt/taplo_fmtnpx jsr add @fmt/taplo-fmtUsage
Node.js / Deno / Bun / Bundler
import { format } from "@wasm-fmt/taplo_fmt";
const input = `name = "example"
version = "0.1.0"
[dependencies]
serde = "1.0"`;
const formatted = format(input);
console.log(formatted);with custom options:
import { format } from "@wasm-fmt/taplo_fmt";
const input = `name = "example"
version = "0.1.0"
[dependencies]
serde = "1.0"`;
const formatted = format(input, {
column_width: 80,
indent_entries: true,
align_entries: true,
align_comments: true,
});
console.log(formatted);Node.js < 22.19
import { format } from "@wasm-fmt/taplo_fmt/node";Web
For web environments, you need to initialize the WASM module manually:
import init, { format } from "@wasm-fmt/taplo_fmt/web";
await init();
const input = `name = "example"
version = "0.1.0"
[dependencies]
serde = "1.0"`;
const formatted = format(input);
console.log(formatted);Vite
import init, { format } from "@wasm-fmt/taplo_fmt/vite";
await init();
// ...Entry Points
.- Auto-detects environment (Node.js uses node, Webpack uses bundler, default is ESM)./node- Node.js environment (no init required)./esm- ESM environments like Deno (no init required)./bundler- Bundlers like Webpack (no init required)./web- Web browsers (requires manual init)./vite- Vite bundler (requires manual init)
Credits
Thanks to:
- The Taplo project created by Ferenc Tamás
