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(yaml): rename ParseOptions.json to ParseOptions.allowDuplicateKeys #5282

Merged
merged 4 commits into from
Jul 4, 2024

Conversation

iuioiua
Copy link
Collaborator

@iuioiua iuioiua commented Jul 3, 2024

What's changed

ParseOptions.json has been renamed ParseOptions.allowDuplicateKeys. This change only affects those that previously set ParseOptions.json to true. No changes in behavior have been made.

Motivation

This name more clearly describes how the option affects the behavior of parse().

Migration guide

To migrate, use the allowDuplicateKeys option instead of the json option for parse().

import { parse } from "@std/yaml/parse";

const yamlString = `name: John Doe
age: 30
name: Jane Doe`;

- parse(yamlString, { json: true });
+ parse(yamlString, { allowDuplicateKeys: true });

Related

Towards #5195

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (fc2975b) to head (7cc1684).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5282   +/-   ##
=======================================
  Coverage   95.76%   95.76%           
=======================================
  Files         457      457           
  Lines       37955    37955           
  Branches     5569     5569           
=======================================
  Hits        36346    36346           
  Misses       1568     1568           
  Partials       41       41           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kt3k
Copy link
Member

kt3k commented Jul 4, 2024

I'm in favor of this change. The option name json doesn't describe what it changes.

I slightly feel allowDuplicatedKeys is a bit more natural. What do you think?

@iuioiua
Copy link
Collaborator Author

iuioiua commented Jul 4, 2024

I slightly feel allowDuplicatedKeys is a bit more natural. What do you think?

I don't think it's any more natural than what it is now.

@iuioiua
Copy link
Collaborator Author

iuioiua commented Jul 4, 2024

I did a quick search - "duplicate keys" seems more correct.

@@ -14,7 +14,7 @@ export interface ParseOptions {
/** Name of the schema to use.*/
schema?: "core" | "default" | "failsafe" | "json" | "extended";
/** compatibility with JSON.parse behaviour. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also change the description

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be reworking docs for all of @std/yaml once the breaking changes are made.

@iuioiua iuioiua enabled auto-merge (squash) July 4, 2024 03:58
@iuioiua iuioiua disabled auto-merge July 4, 2024 03:59
@iuioiua iuioiua requested a review from kt3k July 4, 2024 04:54
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iuioiua iuioiua merged commit f3ca458 into main Jul 4, 2024
12 checks passed
@iuioiua iuioiua deleted the yaml-rename-json-allowDuplicateKeys branch July 4, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants