Node.js
tombi-lib is a native Node.js addon for server-side JavaScript such as CLI tools,
build scripts, and servers. It runs without WASM initialization and can read
tombi.toml from the file system.
To run Tombi in a browser, use tombi-wasm-lib
instead.
Install
npm install tombi-libUsage
import { format, lint } from "tombi-lib";
const { formatted } = await format("key=1", "example.toml");
console.log(formatted); // key = 1
const { diagnostics } = await lint("key =", "example.toml");
for (const diagnostic of diagnostics) {
console.log(diagnostic.level, diagnostic.message);
}formatSync / lintSync are also available when a synchronous call is needed:
import { formatSync } from "tombi-lib";
const { formatted } = formatSync("key=1", "example.toml");Configuration
By default, tombi.toml is searched from the current directory.
Pass config to use an in-memory configuration instead:
await format(source, "Cargo.toml", { config: "[format.rules]\nindent-width = 4\n" });