Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export {
isNode,
isPair,
isScalar,
isMergeKey,
MERGE_KEY,
isSeq
} from './nodes/identity.ts'
export type { Node, ParsedNode, Range } from './nodes/Node.ts'
Expand Down
2 changes: 2 additions & 0 deletions src/nodes/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type { Scalar } from './Scalar.ts'
import type { YAMLMap } from './YAMLMap.ts'
import type { YAMLSeq } from './YAMLSeq.ts'

export { isMergeKey, MERGE_KEY } from '../schema/yaml-1.1/merge.ts'

export const ALIAS: unique symbol = Symbol.for('yaml.alias')
export const DOC: unique symbol = Symbol.for('yaml.document')
export const MAP: unique symbol = Symbol.for('yaml.map')
Expand Down
4 changes: 2 additions & 2 deletions src/schema/yaml-1.1/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ScalarTag } from '../types.ts'
// Keys in mapping nodes earlier in the sequence override keys specified in
// 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 = '<<'


export const merge: ScalarTag & {
identify(value: unknown): boolean
Expand All @@ -23,7 +23,7 @@ export const merge: ScalarTag & {
(typeof value === 'symbol' && value.description === 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: /^<<$/,

resolve: () =>
Object.assign(new Scalar(Symbol(MERGE_KEY)), {
addToJSMap: addMergeToJSMap
Expand Down
Loading