Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions ini/stringify.ts
Original file line number Diff line number Diff line change
@@ -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. Ignored on parse.
kt3k marked this conversation as resolved.
Show resolved Hide resolved
*
* @default {"\n"}
*/
lineBreak?: "\n" | "\r\n" | "\r";
/**
* Use a plain assignment char or pad with spaces. Ignored on parse.
kt3k marked this conversation as resolved.
Show resolved Hide resolved
*
* @default {false}
*/
pretty?: boolean;
/**
* Provide custom string conversion for the value in a key/value pair.
* Similar to the
Expand All @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions ini/stringify_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down