Skip to main content

@std/toml@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score76%
Published2 years ago (0.215.0)
default

parse and stringify for handling TOML encoded data. Be sure to read the supported types as not every spec is supported at the moment and the handling in TypeScript side is a bit different.

Examples

Example 1

import {
  parse,
  stringify,
} from "@std/toml";
const obj = {
  bin: [
    { name: "deno", path: "cli/main.rs" },
    { name: "deno_core", path: "src/foo.rs" },
  ],
  nib: [{ name: "node", path: "not_found" }],
};
const tomlString = stringify(obj);
console.log(tomlString);

// =>
// [[bin]]
// name = "deno"
// path = "cli/main.rs"

// [[bin]]
// name = "deno_core"
// path = "src/foo.rs"

// [[nib]]
// name = "node"
// path = "not_found"

const tomlObject = parse(tomlString);
console.log(tomlObject);

// =>
// {
//   bin: [
//     { name: "deno", path: "cli/main.rs" },
//     { name: "deno_core", path: "src/foo.rs" }
//   ],
//   nib: [ { name: "node", path: "not_found" } ]
// }

Functions

f
parse(tomlString: string): Record<string, unknown>

Parse parses TOML string into an object.

f
stringify(
srcObj: Record<string, unknown>,
fmtOptions?: FormatOptions
): string

Stringify dumps source object into TOML string and returns it.

Interfaces

I

Formatting Options for stringify

  • keyAlignment: boolean

    Define if the keys should be aligned or not

parse

Functions

f
parse(tomlString: string): Record<string, unknown>

Parse parses TOML string into an object.

stringify

Functions

f
stringify(
srcObj: Record<string, unknown>,
fmtOptions?: FormatOptions
): string

Stringify dumps source object into TOML string and returns it.

Interfaces

I

Formatting Options for stringify

  • keyAlignment: boolean

    Define if the keys should be aligned or not

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/toml

Import symbol

import * as toml from "@std/toml";
or

Import directly with a jsr specifier

import * as toml from "jsr:@std/toml";