BREAKING(ini): reduce options for stringify, make FormattingOptions type private (#5572)

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Yoshiya Hinosawa 2024-07-30 11:31:39 +09:00 committed by GitHub
parent 3a446538b1
commit aa8bb2b28b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 11 deletions

View File

@ -1,14 +1,22 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import {
type FormattingOptions,
IniMap,
type ReplacerFunction,
} from "./_ini_map.ts";
import { IniMap, type ReplacerFunction } from "./_ini_map.ts";
/** Options for {@linkcode stringify}. */
export interface StringifyOptions extends FormattingOptions {
export interface StringifyOptions {
/**
* Character(s) used to break lines in the config file.
*
* @default {"\n"}
*/
lineBreak?: "\n" | "\r\n" | "\r";
/**
* Use a plain assignment char or pad with spaces.
*
* @default {false}
*/
pretty?: boolean;
/**
* Provide custom string conversion for the value in a key/value pair.
* Similar to the
@ -18,7 +26,7 @@ export interface StringifyOptions extends FormattingOptions {
replacer?: ReplacerFunction;
}
export type { FormattingOptions, ReplacerFunction };
export type { ReplacerFunction };
/**
* Compile an object into an INI config string. Provide formatting options to modify the output.

View File

@ -18,10 +18,6 @@ Deno.test({
fn() {
assertValidStringify({ a: "b" }, `a=b`);
assertValidStringify({ a: "b" }, `a = b`, { pretty: true });
assertValidStringify({ a: "b" }, `a : b`, {
assignment: ":",
pretty: true,
});
assertValidStringify(
{ a: "b", section: { c: "d" }, e: "f" },
`a=b\ne=f\n[section]\nc=d`,