// 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);
}

// denoCacheMetadata={"headers":{"server":"cloudflare","cf-ray":"a223e658ad237db6-LAX","content-type":"text/typescript","age":"41384","x-content-type-options":"nosniff","x-jsr-backend":"modules","content-length":"820","set-cookie":"__cf_bm=7i2bw5KbBczG4CUAvP6kJ1vqaTOq.4Axfy7ISbBFYnw-1785241875.3071387-1.0.1.1-pIqGItEK0lhdwoPApe87H7Amd5q..htP6oSSDH9FjsnMLqljafObk9y.Q7TzZiRYtUCl6hXIkF3C2WyEgHxjiMScnexsbYMLkaMtbZKlh4uOpLtlaUEjGklmKiWsWz0L; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","cache-control":"public, max-age=31536000, immutable","cross-origin-resource-policy":"cross-origin","x-robots-tag":"noindex","accept-ranges":"bytes","date":"Tue, 28 Jul 2026 12:31:15 GMT","vary":"Origin","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=ELjPyOnJhQLy14mNGyBb%2BENkBxD63LvXP5bA1ZE4pJ3CbpmduSVOVf4bDcHIyXbphk2o1a6YwJ%2BlQl52JQmz%2B%2Fz0D1NVruim2Vh2HYt3%2BUvl4SkdMQ5KpPs%3D\"}]}","cf-cache-status":"HIT","access-control-expose-headers":"*","access-control-allow-origin":"*","etag":"\"7fb7299a59b8226606e648284de9fd7b\"","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","alt-svc":"h3=\":443\"; ma=86400"},"url":"https://jsr.io/@std/toml/1.0.1/parse.ts","time":1785241875}