From 535acf12642d5587243ce74060f97c03faffe540 Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Sat, 10 Jan 2026 12:59:21 +0000 Subject: [PATCH 1/4] feat: Expose `isMergeKey` as util --- src/util.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util.ts b/src/util.ts index d1b9aa83..8bee2b1c 100644 --- a/src/util.ts +++ b/src/util.ts @@ -9,6 +9,7 @@ export { findPair } from './nodes/YAMLMap.ts' export { map as mapTag } from './schema/common/map.ts' export { seq as seqTag } from './schema/common/seq.ts' export { string as stringTag } from './schema/common/string.ts' +export { isMergeKey } from './schema/yaml-1.1/merge.ts' export { foldFlowLines } from './stringify/foldFlowLines.ts' export type { FoldOptions } from './stringify/foldFlowLines.ts' export type { StringifyContext } from './stringify/stringify.ts' From 5ee0ec80b7c346f2bb7e040f8feb591f21e1ceba Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Thu, 15 Jan 2026 18:15:01 +0000 Subject: [PATCH 2/4] feat: export `MERGE_KEY` constant --- src/schema/yaml-1.1/merge.ts | 2 +- src/util.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schema/yaml-1.1/merge.ts b/src/schema/yaml-1.1/merge.ts index e8f449ac..2e9b580e 100644 --- a/src/schema/yaml-1.1/merge.ts +++ b/src/schema/yaml-1.1/merge.ts @@ -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 = '<<' export const merge: ScalarTag & { identify(value: unknown): boolean diff --git a/src/util.ts b/src/util.ts index 8bee2b1c..d89b2e06 100644 --- a/src/util.ts +++ b/src/util.ts @@ -9,7 +9,7 @@ export { findPair } from './nodes/YAMLMap.ts' export { map as mapTag } from './schema/common/map.ts' export { seq as seqTag } from './schema/common/seq.ts' export { string as stringTag } from './schema/common/string.ts' -export { isMergeKey } from './schema/yaml-1.1/merge.ts' +export { isMergeKey, MERGE_KEY } from './schema/yaml-1.1/merge.ts' export { foldFlowLines } from './stringify/foldFlowLines.ts' export type { FoldOptions } from './stringify/foldFlowLines.ts' export type { StringifyContext } from './stringify/stringify.ts' From 4043e49eeeca6de66151c8937fb1154dba1d3ca7 Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Thu, 15 Jan 2026 18:15:52 +0000 Subject: [PATCH 3/4] style: reuse `MERGE_KEY` regex --- src/schema/yaml-1.1/merge.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schema/yaml-1.1/merge.ts b/src/schema/yaml-1.1/merge.ts index 2e9b580e..ff0350c0 100644 --- a/src/schema/yaml-1.1/merge.ts +++ b/src/schema/yaml-1.1/merge.ts @@ -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}$`), resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), { addToJSMap: addMergeToJSMap From 2e84d2142b977b0c5620d5603cb6442174dade5b Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Tue, 20 Jan 2026 23:55:37 +0000 Subject: [PATCH 4/4] refactor: move merge key `export`s to identity --- src/index.ts | 2 ++ src/nodes/identity.ts | 2 ++ src/util.ts | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e4082837..6d09cf8d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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' diff --git a/src/nodes/identity.ts b/src/nodes/identity.ts index 9f1fba2f..f98099dd 100644 --- a/src/nodes/identity.ts +++ b/src/nodes/identity.ts @@ -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') diff --git a/src/util.ts b/src/util.ts index d89b2e06..d1b9aa83 100644 --- a/src/util.ts +++ b/src/util.ts @@ -9,7 +9,6 @@ export { findPair } from './nodes/YAMLMap.ts' export { map as mapTag } from './schema/common/map.ts' export { seq as seqTag } from './schema/common/seq.ts' export { string as stringTag } from './schema/common/string.ts' -export { isMergeKey, MERGE_KEY } from './schema/yaml-1.1/merge.ts' export { foldFlowLines } from './stringify/foldFlowLines.ts' export type { FoldOptions } from './stringify/foldFlowLines.ts' export type { StringifyContext } from './stringify/stringify.ts'