Skip to content

LLM Resources

@structium/toml - API documentation ​

Functions ​

deserialize() ​

ts
function deserialize<Res>(content: string, options?: ParseOptions): Promise<Res>

Deserialize a TOML string into a JavaScript object.

Type Parameters ​

Type ParameterDefault typeDescription
Res extends CommonObjCommonObjThe expected return type of the deserialized object

Parameters ​

ParameterTypeDescription
contentstringThe TOML content string
options?ParseOptionsOptions

Returns ​

Promise<Res>

  • The deserialized JavaScript object

Example ​

ts
const tomlContent = `
  name = "Alice"
  age = 30
  city = "New York"
`

const obj = await deserialize( tomlContent )
console.log( obj )

serialize() ​

ts
function serialize(content: object, options?: {}): Promise<string>

Serialize a JavaScript object to a TOML string.

Parameters ​

ParameterTypeDescription
contentobjectAn object that will be serialized to a TOML string.
options?objectOptions

Returns ​

Promise<string>

A TOML string.