Skip to content

Conversation

@danielbayley
Copy link
Contributor

@danielbayley danielbayley commented Jan 10, 2026

Trying to use isMergeKey for something… Is there a reason it isn’t exposed alongside isScalar etc? Also, seems like MERGE_KEY should be a shared symbol, no?

// later mapping nodes. -- http://yaml.org/type/merge.html

const MERGE_KEY = '<<'
export const MERGE_KEY: unique symbol = Symbol.for('<<')
Copy link
Owner

Choose a reason for hiding this comment

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

Probably best to roll back this change.

Currently, main has changes that will only get released as a v3 release of the library, so if you want/need isMergeKey to be available on v2, this PR needs to not include breaking changes.

For v3, I intend to be much stricter on the values that can be put in a document, and so for something like merge keys, end up with an instanceof check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for something like merge keys, end up with an instanceof check.

I thought about instanceof, but that operator doesn’t work on Symbols, which seem like the best fit for merge keys, surely?

this PR needs to not include breaking changes.

Would exporting MERGE_KEY as a shared Symbol even be a breaking change, given that it seems to only currently exist within this file?

Probably best to roll back this change.

Have rolled back to just exporting MERGE_KEY as string for now/v2…

@danielbayley danielbayley changed the title feat: Expose isMergeKey as util feat: Expose isMergeKey and MERGE_KEY constant Jan 20, 2026
// later mapping nodes. -- http://yaml.org/type/merge.html

const MERGE_KEY = '<<'
export const MERGE_KEY = '<<'
Copy link
Owner

Choose a reason for hiding this comment

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

As I mention in my previous review, I intend to make type checking stricter in v3. To that end, we shouldn't be exposing MERGE_KEY, but providing and enforcing the use of a new Merge class for this purpose.

Suggested change
export const MERGE_KEY = '<<'
const MERGE_KEY = '<<'

default: 'key',
tag: 'tag:yaml.org,2002:merge',
test: /^<<$/,
test: new RegExp(`^${MERGE_KEY}$`),
Copy link
Owner

Choose a reason for hiding this comment

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

This isn't really making the code more legible.

Suggested change
test: new RegExp(`^${MERGE_KEY}$`),
test: /^<<$/,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants