@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 Parameter | Default type | Description |
|---|---|---|
Res extends CommonObj | CommonObj | The expected return type of the deserialized object |
Parameters β
| Parameter | Type | Description |
|---|---|---|
content | string | The TOML content string |
options? | ParseOptions | Options |
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 β
| Parameter | Type | Description |
|---|---|---|
content | object | An object that will be serialized to a TOML string. |
options? | object | Options |
Returns β
Promise<string>
A TOML string.
