UNPKG

keep-a-changelog

Version:

Node package to parse and generate changelogs following the [keepachangelog](https://keepachangelog.com/) format.

63 lines (62 loc) 1.52 kB
"use strict"; // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = parse; const ini_map_js_1 = require("./ini_map.js"); /** * Parse an INI config string into an object. Provide formatting options to override the default assignment operator. * * @example Usage * ```ts * import { parse } from "@std/ini/parse"; * import { assertEquals } from "@std/assert"; * * const parsed = parse(` * key = value * * [section 1] * foo = Hello * baz = World * `); * * assertEquals(parsed, { key: "value", "section 1": { foo: "Hello", baz: "World" } }) * ``` * * @example Using custom reviver * ```ts * import { parse } from "@std/ini/parse"; * import { assertEquals } from "@std/assert"; * * const parsed = parse(` * [section Foo] * date = 2012-10-10 * amount = 12345 * `, { * reviver(key, value, section) { * if (section === "section Foo") { * if (key === "date") { * return new Date(value); * } else if (key === "amount") { * return +value; * } * } * return value; * } * }); * * assertEquals(parsed, { * "section Foo": { * date: new Date("2012-10-10"), * amount: 12345, * } * }) * ``` * * @param text The text to parse * @param options The options to use * @return The parsed object */ function parse(text, options) { return ini_map_js_1.IniMap.from(text, options).toObject(); }