mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
ce0c1e2cfb
initial commit
28 lines
820 B
TypeScript
28 lines
820 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
// This module is browser compatible.
|
|
|
|
import { parserFactory, toml } from "./_parser.ts";
|
|
|
|
/**
|
|
* Parses a {@link https://toml.io | TOML} string into an object.
|
|
*
|
|
* @example Usage
|
|
* ```ts
|
|
* import { parse } from "@std/toml/parse";
|
|
* import { assertEquals } from "@std/assert";
|
|
*
|
|
* const tomlString = `title = "TOML Example"
|
|
* [owner]
|
|
* name = "Alice"
|
|
* bio = "Alice is a programmer."`;
|
|
*
|
|
* const obj = parse(tomlString);
|
|
* assertEquals(obj, { title: "TOML Example", owner: { name: "Alice", bio: "Alice is a programmer." } });
|
|
* ```
|
|
* @param tomlString TOML string to be parsed.
|
|
* @returns The parsed JS object.
|
|
*/
|
|
export function parse(tomlString: string): Record<string, unknown> {
|
|
return parserFactory(toml)(tomlString);
|
|
}
|