namespace
TOML
namespace TOML
TOML related APIs
- ): object;
Parse a TOML (v1.1.0) document into a JavaScript object.
Date/time values parse as Temporal objects: offset date-times as
Temporal.Instant, local date-times asTemporal.PlainDateTime, local dates asTemporal.PlainDate, and local times asTemporal.PlainTime. Integers outsideNumber.MAX_SAFE_INTEGERthrow, since they cannot be represented losslessly as JavaScript numbers.@param inputThe TOML document to parse, as a string or UTF-8 bytes
@returnsA JavaScript object
- input: unknown,replacer?: null,space?: string | number): undefined | string;
Serialize a JavaScript object to a TOML document.
The top-level value must be an object (a TOML document is a table).
Temporal.Instant,Temporal.PlainDateTime,Temporal.PlainDate, andTemporal.PlainTimevalues become the corresponding TOML date/time literals,Temporal.ZonedDateTimebecomes an offset date-time, andDatebecomes an offset date-time in UTC; time-zone and calendar annotations are dropped, since TOML has no syntax for them.null,BigInt, circular structures, invalidDates, date values outside years 0000–9999, and Temporal types with no TOML form (Temporal.PlainYearMonth,Temporal.PlainMonthDay,Temporal.Duration) throw, since TOML cannot represent them;undefined, function, and symbol properties are skipped (inside arrays they throw, since TOML arrays cannot have holes).@param inputThe JavaScript object to serialize.
@param replacerNot supported; pass
undefinedornull.@param spaceAccepted for signature parity with
YAML.stringifyandJSON5.stringify, but ignored: TOML output is line-oriented.@returnsA TOML document string, or
undefinedif the input isundefined, a function, or a symbol.import { TOML } from "bun"; TOML.stringify({ name: "app", server: { port: 8080 } }); // 'name = "app"\n\n[server]\nport = 8080\n'