yaml 3.0.0-1 → 3.0.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
1
  //#region src/parse/line-counter.d.ts
2
2
  /**
3
- * Tracks newlines during parsing in order to provide an efficient API for
4
- * determining the one-indexed `{ line, col }` position for any offset
5
- * within the input.
6
- */
3
+ * Tracks newlines during parsing in order to provide an efficient API for
4
+ * determining the one-indexed `{ line, col }` position for any offset
5
+ * within the input.
6
+ */
7
7
  declare class LineCounter {
8
8
  lineStarts: number[];
9
9
  /**
10
- * Should be called in ascending order. Otherwise, call
11
- * `lineCounter.lineStarts.sort()` before calling `linePos()`.
12
- */
10
+ * Should be called in ascending order. Otherwise, call
11
+ * `lineCounter.lineStarts.sort()` before calling `linePos()`.
12
+ */
13
13
  addNewLine: (offset: number) => number;
14
14
  /**
15
- * Performs a binary search and returns the 1-indexed { line, col }
16
- * position of `offset`. If `line === 0`, `addNewLine` has never been
17
- * called or `offset` is before the first known newline.
18
- */
15
+ * Performs a binary search and returns the 1-indexed { line, col }
16
+ * position of `offset`. If `line === 0`, `addNewLine` has never been
17
+ * called or `offset` is before the first known newline.
18
+ */
19
19
  linePos: (offset: number) => {
20
20
  line: number;
21
21
  col: number;
@@ -72,6 +72,7 @@ type StringifyContext = {
72
72
  //#region src/nodes/toJS.d.ts
73
73
  /** A context used in `node.toJS()` implementations */
74
74
  declare class ToJSContext {
75
+ #private;
75
76
  anchors: Map<Node, {
76
77
  aliasCount: number;
77
78
  count: number;
@@ -84,6 +85,7 @@ declare class ToJSContext {
84
85
  maxAliasCount: number;
85
86
  constructor(opt?: ToJSOptions);
86
87
  setAnchor(node: Node, res: unknown): void;
88
+ resolveAlias(doc: Document, source: Node): unknown;
87
89
  }
88
90
  //#endregion
89
91
  //#region src/doc/NodeCreator.d.ts
@@ -97,10 +99,10 @@ declare class NodeCreator {
97
99
  create(value: unknown, tagName?: string): Node;
98
100
  createPair(key: unknown, value: unknown): Pair<Node, Node | null>;
99
101
  /**
100
- * With circular references, the source node is only resolved after all
101
- * of its child nodes are. This is why anchors are set only after all of
102
- * the nodes have been created.
103
- */
102
+ * With circular references, the source node is only resolved after all
103
+ * of its child nodes are. This is why anchors are set only after all of
104
+ * the nodes have been created.
105
+ */
104
106
  setAnchors(): void;
105
107
  }
106
108
  //#endregion
@@ -127,22 +129,22 @@ declare class Scalar<T = unknown> implements NodeBase {
127
129
  /** A comment before this node. */
128
130
  commentBefore?: string | null;
129
131
  /**
130
- * By default (undefined), numbers use decimal notation.
131
- * The YAML 1.2 core schema only supports 'HEX' and 'OCT'.
132
- * The YAML 1.1 schema also supports 'BIN' and 'TIME'
133
- */
132
+ * By default (undefined), numbers use decimal notation.
133
+ * The YAML 1.2 core schema only supports 'HEX' and 'OCT'.
134
+ * The YAML 1.1 schema also supports 'BIN' and 'TIME'
135
+ */
134
136
  format?: string;
135
137
  /**
136
- * If `value` is a number that is serialized as a decimal string
137
- * (i.e. not using exponential notation),
138
- * use this value when stringifying this node.
139
- */
138
+ * If `value` is a number that is serialized as a decimal string
139
+ * (i.e. not using exponential notation),
140
+ * use this value when stringifying this node.
141
+ */
140
142
  minFractionDigits?: number;
141
143
  /**
142
- * The `[start, value-end, node-end]` character offsets for
143
- * the part of the source parsed into this node (undefined if not parsed).
144
- * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
145
- */
144
+ * The `[start, value-end, node-end]` character offsets for
145
+ * the part of the source parsed into this node (undefined if not parsed).
146
+ * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
147
+ */
146
148
  range?: Range | null;
147
149
  /** A blank line before this node and its commentBefore */
148
150
  spaceBefore?: boolean;
@@ -155,10 +157,10 @@ declare class Scalar<T = unknown> implements NodeBase {
155
157
  /** The scalar style used for the node's string representation */
156
158
  type?: Scalar.Type;
157
159
  /**
158
- * Customize the way that a key-value pair is resolved.
159
- * Used for YAML 1.1 !!merge << handling.
160
- */
161
- addToJSMap?: (doc: Document<DocValue, boolean>, ctx: ToJSContext | undefined, map: MapLike, value: unknown) => void;
160
+ * Customize the way that a key-value pair is resolved.
161
+ * Used for YAML 1.1 !!merge << handling.
162
+ */
163
+ addToJSMap?: (doc: Document<DocValue, boolean>, ctx: ToJSContext | undefined, map: MapLike, value: unknown, isPlainObject: boolean) => void;
162
164
  constructor(value: T);
163
165
  /** Create a copy of this node. */
164
166
  clone(): this;
@@ -184,10 +186,10 @@ declare class YAMLMap<K extends Primitive | Node = Primitive | Node, V extends P
184
186
  /** A comment before this map. */
185
187
  commentBefore?: string | null;
186
188
  /**
187
- * The `[start, value-end, node-end]` character offsets for
188
- * the part of the source parsed into this map (undefined if not parsed).
189
- * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
190
- */
189
+ * The `[start, value-end, node-end]` character offsets for
190
+ * the part of the source parsed into this map (undefined if not parsed).
191
+ * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
192
+ */
191
193
  range?: Range | null;
192
194
  /** A blank line before this map and its commentBefore */
193
195
  spaceBefore?: boolean;
@@ -196,22 +198,22 @@ declare class YAMLMap<K extends Primitive | Node = Primitive | Node, V extends P
196
198
  /** A fully qualified tag, if required */
197
199
  tag?: string;
198
200
  /**
199
- * A generic collection factory method that can be used
200
- * by other node classes that inherit from YAMLMap
201
- */
201
+ * A generic collection factory method that can be used
202
+ * by other node classes that inherit from YAMLMap
203
+ */
202
204
  static create(nc: NodeCreator, obj: unknown): YAMLMap<any, any>;
203
205
  constructor(schema: Schema, elements?: Array<Pair<K, V>>);
204
206
  get size(): number;
205
207
  /**
206
- * Create a copy of this map.
207
- *
208
- * @param schema - If defined, overwrites the original's schema
209
- */
208
+ * Create a copy of this map.
209
+ *
210
+ * @param schema - If defined, overwrites the original's schema
211
+ */
210
212
  clone(schema?: Schema): this;
211
213
  /**
212
- * Remove a value from the mapping.
213
- * @returns `true` if the item was found and removed.
214
- */
214
+ * Remove a value from the mapping.
215
+ * @returns `true` if the item was found and removed.
216
+ */
215
217
  delete(key: KeyArg<K, V>): boolean;
216
218
  /** Return value at `key`, or `undefined` if not found. */
217
219
  get(key: KeyArg<K, V>): NodeOf<V> | null | undefined;
@@ -220,21 +222,21 @@ declare class YAMLMap<K extends Primitive | Node = Primitive | Node, V extends P
220
222
  /** Check if the mapping includes a value with the key `key`. */
221
223
  has(key: KeyArg<K, V>): boolean;
222
224
  /**
223
- * Return the internal Map key matching `key`, or `undefined` if not found.
224
- *
225
- * @param allowMissing - If `true`, a key is always returned,
226
- * even if the key is not in the map.
227
- */
225
+ * Return the internal Map key matching `key`, or `undefined` if not found.
226
+ *
227
+ * @param allowMissing - If `true`, a key is always returned,
228
+ * even if the key is not in the map.
229
+ */
228
230
  keyOf(key: KeyArg<K, V>, allowMissing?: boolean): unknown;
229
231
  pairs(): Iterable<Pair<K, V>>;
230
232
  set(key: K | NodeOf<K> | (K extends Scalar ? K["value"] : never), value: V | NodeOf<V> | (V extends Scalar ? V["value"] : never) | null, options?: Omit<CreateNodeOptions, "aliasDuplicateObjects">): this;
231
233
  set(pair: Pair<K, V>): this;
232
234
  /**
233
- * A plain JavaScript representation of this node.
234
- *
235
- * @param Type - If set, forces the returned collection type
236
- * @returns Instance of Type, Map, or Object
237
- */
235
+ * A plain JavaScript representation of this node.
236
+ *
237
+ * @param Type - If set, forces the returned collection type
238
+ * @returns Instance of Type, Map, or Object
239
+ */
238
240
  toJS<T extends MapLike = Map<any, any>>(doc: Document<DocValue, boolean>, ctx: ToJSContext | undefined, Type: {
239
241
  new (): T;
240
242
  }): T;
@@ -243,10 +245,7 @@ declare class YAMLMap<K extends Primitive | Node = Primitive | Node, V extends P
243
245
  }
244
246
  //#endregion
245
247
  //#region src/nodes/addPairToJSMap.d.ts
246
- declare function addPairToJSMap(doc: Document<DocValue, boolean>, ctx: ToJSContext, map: MapLike, {
247
- key,
248
- value
249
- }: Pair): MapLike;
248
+ declare function addPairToJSMap(doc: Document<DocValue, boolean>, ctx: ToJSContext, map: MapLike, { key, value }: Pair, isPlainObject: boolean): MapLike;
250
249
  //#endregion
251
250
  //#region src/nodes/Pair.d.ts
252
251
  declare class Pair<K extends Primitive | Node = Primitive | Node, V extends Primitive | Node = Primitive | Node> {
@@ -266,62 +265,62 @@ declare class Pair<K extends Primitive | Node = Primitive | Node, V extends Prim
266
265
  //#region src/schema/types.d.ts
267
266
  interface TagBase {
268
267
  /**
269
- * An optional factory function, used e.g. by collections when wrapping JS objects as AST nodes.
270
- */
268
+ * An optional factory function, used e.g. by collections when wrapping JS objects as AST nodes.
269
+ */
271
270
  createNode?: (nc: NodeCreator, value: unknown) => Node;
272
271
  /**
273
- * If `true`, allows for values to be stringified without
274
- * an explicit tag together with `test`.
275
- * If `'key'`, this only applies if the value is used as a mapping key.
276
- * For most cases, it's unlikely that you'll actually want to use this,
277
- * even if you first think you do.
278
- */
272
+ * If `true`, allows for values to be stringified without
273
+ * an explicit tag together with `test`.
274
+ * If `'key'`, this only applies if the value is used as a mapping key.
275
+ * For most cases, it's unlikely that you'll actually want to use this,
276
+ * even if you first think you do.
277
+ */
279
278
  default?: boolean | "key";
280
279
  /**
281
- * If a tag has multiple forms that should be parsed and/or stringified
282
- * differently, use `format` to identify them.
283
- */
280
+ * If a tag has multiple forms that should be parsed and/or stringified
281
+ * differently, use `format` to identify them.
282
+ */
284
283
  format?: string;
285
284
  /**
286
- * Used by `YAML.createNode` to detect your data type, e.g. using `typeof` or
287
- * `instanceof`.
288
- */
285
+ * Used by `YAML.createNode` to detect your data type, e.g. using `typeof` or
286
+ * `instanceof`.
287
+ */
289
288
  identify?: (value: unknown) => boolean;
290
289
  /**
291
- * The identifier for your data type, with which its stringified form will be
292
- * prefixed. Should either be a !-prefixed local `!tag`, or a fully qualified
293
- * `tag:domain,date:foo`.
294
- */
290
+ * The identifier for your data type, with which its stringified form will be
291
+ * prefixed. Should either be a !-prefixed local `!tag`, or a fully qualified
292
+ * `tag:domain,date:foo`.
293
+ */
295
294
  tag: string;
296
295
  }
297
296
  interface ScalarTag extends TagBase {
298
297
  collection?: never;
299
298
  nodeClass?: never;
300
299
  /**
301
- * Turns a value into an AST node.
302
- * If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
303
- */
300
+ * Turns a value into an AST node.
301
+ * If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
302
+ */
304
303
  resolve(value: string, onError: (message: string) => void, options: ParseOptions): unknown;
305
304
  /**
306
- * Optional function stringifying a Scalar node. If your data includes a
307
- * suitable `.toString()` method, you can probably leave this undefined and
308
- * use the default stringifier.
309
- *
310
- * @param item The node being stringified.
311
- * @param ctx Contains the stringifying context variables.
312
- * @param onComment Callback to signal that the stringifier includes the
313
- * item's comment in its output.
314
- * @param onChompKeep Callback to signal that the output uses a block scalar
315
- * type with the `+` chomping indicator.
316
- */
305
+ * Optional function stringifying a Scalar node. If your data includes a
306
+ * suitable `.toString()` method, you can probably leave this undefined and
307
+ * use the default stringifier.
308
+ *
309
+ * @param item The node being stringified.
310
+ * @param ctx Contains the stringifying context variables.
311
+ * @param onComment Callback to signal that the stringifier includes the
312
+ * item's comment in its output.
313
+ * @param onChompKeep Callback to signal that the output uses a block scalar
314
+ * type with the `+` chomping indicator.
315
+ */
317
316
  stringify?: (item: Scalar, ctx: StringifyContext, onComment?: () => void, onChompKeep?: () => void) => string;
318
317
  /**
319
- * Together with `default` allows for values to be stringified without an
320
- * explicit tag and detected using a regular expression. For most cases, it's
321
- * unlikely that you'll actually want to use these, even if you first think
322
- * you do.
323
- */
324
- test?: RegExp;
318
+ * Together with `default` allows for values to be stringified without an
319
+ * explicit tag and detected using a regular expression or a test function.
320
+ * For most cases, it's unlikely that you'll actually want to use these,
321
+ * even if you first think you do.
322
+ */
323
+ test?: (value: string) => boolean;
325
324
  }
326
325
  interface CollectionTag extends TagBase {
327
326
  stringify?: never;
@@ -330,50 +329,46 @@ interface CollectionTag extends TagBase {
330
329
  collection: "map" | "seq";
331
330
  createNode: (nc: NodeCreator, value: unknown) => Node;
332
331
  /**
333
- * The `Node` child class that implements this tag.
334
- * If set, used to select this tag when stringifying.
335
- */
332
+ * The `Node` child class that implements this tag.
333
+ * If set, used to select this tag when stringifying.
334
+ */
336
335
  nodeClass?: {
337
336
  new (schema: Schema): Node;
338
337
  };
339
338
  /**
340
- * Turns a value into an AST node.
341
- * If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
342
- *
343
- * Note: this is required if nodeClass is not provided.
344
- */
339
+ * Turns a value into an AST node.
340
+ * If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
341
+ *
342
+ * Note: this is required if nodeClass is not provided.
343
+ */
345
344
  resolve?: (value: Collection, onError: (message: string) => void, options: ParseOptions) => unknown;
346
345
  }
347
346
  //#endregion
348
347
  //#region src/schema/tags.d.ts
348
+ type WithScalarTagTest = {
349
+ test: (value: string) => boolean;
350
+ };
349
351
  declare const tagsByName: {
350
352
  binary: ScalarTag;
351
- bool: ScalarTag & {
352
- test: RegExp;
353
- };
354
- float: ScalarTag;
355
- floatExp: ScalarTag;
356
- floatNaN: ScalarTag;
357
- floatTime: ScalarTag;
358
- int: ScalarTag;
359
- intHex: ScalarTag;
360
- intOct: ScalarTag;
361
- intTime: ScalarTag;
353
+ bool: ScalarTag & WithScalarTagTest;
354
+ float: ScalarTag & WithScalarTagTest;
355
+ floatExp: ScalarTag & WithScalarTagTest;
356
+ floatNaN: ScalarTag & WithScalarTagTest;
357
+ floatTime: ScalarTag & WithScalarTagTest;
358
+ int: ScalarTag & WithScalarTagTest;
359
+ intHex: ScalarTag & WithScalarTagTest;
360
+ intOct: ScalarTag & WithScalarTagTest;
361
+ intTime: ScalarTag & WithScalarTagTest;
362
362
  map: CollectionTag;
363
363
  merge: ScalarTag & {
364
364
  identify(value: unknown): boolean;
365
- test: RegExp;
366
- };
367
- null: ScalarTag & {
368
- test: RegExp;
369
- };
365
+ } & WithScalarTagTest;
366
+ null: ScalarTag & WithScalarTagTest;
370
367
  omap: CollectionTag;
371
368
  pairs: CollectionTag;
372
369
  seq: CollectionTag;
373
370
  set: CollectionTag;
374
- timestamp: ScalarTag & {
375
- test: RegExp;
376
- };
371
+ timestamp: ScalarTag & WithScalarTagTest;
377
372
  };
378
373
  type TagId = keyof typeof tagsByName;
379
374
  type Tags = Array<ScalarTag | CollectionTag | TagId>;
@@ -381,331 +376,332 @@ type Tags = Array<ScalarTag | CollectionTag | TagId>;
381
376
  //#region src/options.d.ts
382
377
  type ParseOptions = {
383
378
  /**
384
- * Whether integers should be parsed into BigInt rather than number values.
385
- *
386
- * Default: `false`
387
- *
388
- * https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/BigInt
389
- */
379
+ * Whether integers should be parsed into BigInt rather than number values.
380
+ *
381
+ * Default: `false`
382
+ *
383
+ * https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/BigInt
384
+ */
390
385
  intAsBigInt?: boolean;
391
386
  /**
392
- * Include a `srcToken` value on each parsed `Node`, containing the CST token
393
- * that was composed into this node.
394
- *
395
- * Default: `false`
396
- */
387
+ * Include a `srcToken` value on each parsed `Node`, containing the CST token
388
+ * that was composed into this node.
389
+ *
390
+ * Default: `false`
391
+ */
397
392
  keepSourceTokens?: boolean;
398
393
  /**
399
- * If set, newlines will be tracked, to allow for `lineCounter.linePos(offset)`
400
- * to provide the `{ line, col }` positions within the input.
401
- */
394
+ * If set, newlines will be tracked, to allow for `lineCounter.linePos(offset)`
395
+ * to provide the `{ line, col }` positions within the input.
396
+ */
402
397
  lineCounter?: LineCounter;
403
398
  /**
404
- * Include line/col position & node type directly in parse errors.
405
- *
406
- * Default: `true`
407
- */
399
+ * Include line/col position & node type directly in parse errors.
400
+ *
401
+ * Default: `true`
402
+ */
408
403
  prettyErrors?: boolean;
409
404
  /**
410
- * Detect and report errors that are required by the YAML 1.2 spec,
411
- * but are caused by unambiguous content.
412
- *
413
- * Default: `true`
414
- */
405
+ * Detect and report errors that are required by the YAML 1.2 spec,
406
+ * but are caused by unambiguous content.
407
+ *
408
+ * Default: `true`
409
+ */
415
410
  strict?: boolean;
416
411
  /**
417
- * Parse all mapping keys as strings. Treat all non-scalar keys as errors.
418
- *
419
- * Default: `false`
420
- */
412
+ * Parse all mapping keys as strings. Treat all non-scalar keys as errors.
413
+ *
414
+ * Default: `false`
415
+ */
421
416
  stringKeys?: boolean;
422
417
  };
423
418
  type DocumentOptions = {
424
419
  /**
425
- * Control the logging level during parsing
426
- *
427
- * Default: `'warn'`
428
- */
420
+ * Control the logging level during parsing
421
+ *
422
+ * Default: `'warn'`
423
+ */
429
424
  logLevel?: LogLevelId;
430
425
  /**
431
- * The YAML version used by documents without a `%YAML` directive.
432
- *
433
- * Default: `"1.2"`
434
- */
426
+ * The YAML version used by documents without a `%YAML` directive.
427
+ *
428
+ * Default: `"1.2"`
429
+ */
435
430
  version?: "1.1" | "1.2" | "next";
436
431
  };
437
432
  type SchemaOptions = {
438
433
  /**
439
- * When parsing, warn about compatibility issues with the given schema.
440
- * When stringifying, use scalar styles that are parsed correctly
441
- * by the `compat` schema as well as the actual schema.
442
- *
443
- * Default: `null`
444
- */
434
+ * When parsing, warn about compatibility issues with the given schema.
435
+ * When stringifying, use scalar styles that are parsed correctly
436
+ * by the `compat` schema as well as the actual schema.
437
+ *
438
+ * Default: `null`
439
+ */
445
440
  compat?: string | Tags | null;
446
441
  /**
447
- * Array of additional tags to include in the schema, or a function that may
448
- * modify the schema's base tag array.
449
- */
442
+ * Array of additional tags to include in the schema, or a function that may
443
+ * modify the schema's base tag array.
444
+ */
450
445
  customTags?: Tags | ((tags: Tags) => Tags) | null;
451
446
  /**
452
- * Determine an internal Map key representation for map and set values,
453
- * which is used for detecting duplicates and to identify values.
454
- *
455
- * Key equality is based on the SameValueZero algorithm.
456
- *
457
- * If merge keys are enabled by the schema,
458
- * multiple `<<` keys are each considered unique.
459
- */
447
+ * Determine an internal Map key representation for map and set values,
448
+ * which is used for detecting duplicates and to identify values.
449
+ *
450
+ * Key equality is based on the SameValueZero algorithm.
451
+ *
452
+ * If merge keys are enabled by the schema,
453
+ * multiple `<<` keys are each considered unique.
454
+ */
460
455
  mapKey?: (value: unknown) => unknown;
461
456
  /**
462
- * Enable support for `<<` merge keys.
463
- *
464
- * Default: `false` for YAML 1.2, `true` for earlier versions
465
- */
457
+ * Enable support for `<<` merge keys.
458
+ *
459
+ * Default: `false` for YAML 1.2, `true` for earlier versions
460
+ */
466
461
  merge?: boolean;
467
462
  /**
468
- * When using the `'core'` schema, support parsing values with these
469
- * explicit YAML 1.1 tags:
470
- *
471
- * `!!binary`, `!!omap`, `!!pairs`, `!!set`, `!!timestamp`.
472
- *
473
- * Default `true`
474
- */
463
+ * When using the `'core'` schema, support parsing values with these
464
+ * explicit YAML 1.1 tags:
465
+ *
466
+ * `!!binary`, `!!omap`, `!!pairs`, `!!set`, `!!timestamp`.
467
+ *
468
+ * Default `true`
469
+ */
475
470
  resolveKnownTags?: boolean;
476
471
  /**
477
- * The base schema to use.
478
- *
479
- * The core library has built-in support for the following:
480
- * - `'failsafe'`: A minimal schema that parses all scalars as strings
481
- * - `'core'`: The YAML 1.2 core schema
482
- * - `'json'`: The YAML 1.2 JSON schema, with minimal rules for JSON compatibility
483
- * - `'yaml-1.1'`: The YAML 1.1 schema
484
- *
485
- * If using another (custom) schema, the `customTags` array needs to
486
- * fully define the schema's tags.
487
- *
488
- * Default: `'core'` for YAML 1.2, `'yaml-1.1'` for earlier versions
489
- */
472
+ * The base schema to use.
473
+ *
474
+ * The core library has built-in support for the following:
475
+ * - `'failsafe'`: A minimal schema that parses all scalars as strings
476
+ * - `'core'`: The YAML 1.2 core schema
477
+ * - `'json'`: The YAML 1.2 JSON schema, with minimal rules for JSON compatibility
478
+ * - `'yaml-1.1'`: The YAML 1.1 schema
479
+ *
480
+ * If using another (custom) schema, the `customTags` array needs to
481
+ * fully define the schema's tags.
482
+ *
483
+ * Default: `'core'` for YAML 1.2, `'yaml-1.1'` for earlier versions
484
+ */
490
485
  schema?: string | Schema;
491
486
  /**
492
- * Override default values for `toString()` options.
493
- */
487
+ * Override default values for `toString()` options.
488
+ */
494
489
  toStringDefaults?: ToStringOptions;
495
490
  };
496
491
  type CreateNodeOptions = {
497
492
  /**
498
- * During node construction, use anchors and aliases to keep strictly equal
499
- * non-null objects as equivalent in YAML.
500
- *
501
- * Default: `true`
502
- */
493
+ * During node construction, use anchors and aliases to keep strictly equal
494
+ * non-null objects as equivalent in YAML.
495
+ *
496
+ * Default: `true`
497
+ */
503
498
  aliasDuplicateObjects?: boolean;
504
499
  /**
505
- * Default prefix for anchors.
506
- *
507
- * Default: `'a'`, resulting in anchors `a1`, `a2`, etc.
508
- */
509
- anchorPrefix?: string; /** Force the top-level collection node to use flow style. */
500
+ * Default prefix for anchors.
501
+ *
502
+ * Default: `'a'`, resulting in anchors `a1`, `a2`, etc.
503
+ */
504
+ anchorPrefix?: string;
505
+ /** Force the top-level collection node to use flow style. */
510
506
  flow?: boolean;
511
507
  /**
512
- * Keep `undefined` object values when creating mappings, rather than
513
- * discarding them.
514
- *
515
- * Default: `false`
516
- */
508
+ * Keep `undefined` object values when creating mappings, rather than
509
+ * discarding them.
510
+ *
511
+ * Default: `false`
512
+ */
517
513
  keepUndefined?: boolean | null;
518
514
  onTagObj?: (tagObj: ScalarTag | CollectionTag) => void;
519
515
  /**
520
- * Specify the top-level collection type, e.g. `"!!omap"`. Note that this
521
- * requires the corresponding tag to be available in this document's schema.
522
- */
516
+ * Specify the top-level collection type, e.g. `"!!omap"`. Note that this
517
+ * requires the corresponding tag to be available in this document's schema.
518
+ */
523
519
  tag?: string;
524
520
  };
525
521
  type ToJSOptions = {
526
522
  /**
527
- * Use Map rather than Object to represent mappings.
528
- *
529
- * Default: `false`
530
- */
523
+ * Use Map rather than Object to represent mappings.
524
+ *
525
+ * Default: `false`
526
+ */
531
527
  mapAsMap?: boolean;
532
528
  /**
533
- * Prevent exponential entity expansion attacks by limiting data aliasing count;
534
- * set to `-1` to disable checks; `0` disallows all alias nodes.
535
- *
536
- * Default: `100`
537
- */
529
+ * Prevent exponential entity expansion attacks by limiting data aliasing count;
530
+ * set to `-1` to disable checks; `0` disallows all alias nodes.
531
+ *
532
+ * Default: `100`
533
+ */
538
534
  maxAliasCount?: number;
539
535
  /**
540
- * If defined, called with the resolved `value` and reference `count` for
541
- * each anchor in the document.
542
- */
536
+ * If defined, called with the resolved `value` and reference `count` for
537
+ * each anchor in the document.
538
+ */
543
539
  onAnchor?: (value: unknown, count: number) => void;
544
540
  /**
545
- * Optional function that may filter or modify the output JS value
546
- *
547
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#using_the_reviver_parameter
548
- */
541
+ * Optional function that may filter or modify the output JS value
542
+ *
543
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#using_the_reviver_parameter
544
+ */
549
545
  reviver?: Reviver;
550
546
  };
551
547
  type ToStringOptions = {
552
548
  /**
553
- * Use block quote styles for scalar values where applicable.
554
- * Set to `false` to disable block quotes completely.
555
- *
556
- * Default: `true`
557
- */
549
+ * Use block quote styles for scalar values where applicable.
550
+ * Set to `false` to disable block quotes completely.
551
+ *
552
+ * Default: `true`
553
+ */
558
554
  blockQuote?: boolean | "folded" | "literal";
559
555
  /**
560
- * Enforce `'block'` or `'flow'` style on maps and sequences.
561
- * Empty collections will always be stringified as `{}` or `[]`.
562
- *
563
- * Default: `'any'`, allowing each node to set its style separately
564
- * with its `flow: boolean` (default `false`) property.
565
- */
556
+ * Enforce `'block'` or `'flow'` style on maps and sequences.
557
+ * Empty collections will always be stringified as `{}` or `[]`.
558
+ *
559
+ * Default: `'any'`, allowing each node to set its style separately
560
+ * with its `flow: boolean` (default `false`) property.
561
+ */
566
562
  collectionStyle?: "any" | "block" | "flow";
567
563
  /**
568
- * Comment stringifier.
569
- * Output should be valid for the current schema.
570
- *
571
- * By default, empty comment lines are left empty,
572
- * lines consisting of a single space are replaced by `#`,
573
- * and all other lines are prefixed with a `#`.
574
- */
564
+ * Comment stringifier.
565
+ * Output should be valid for the current schema.
566
+ *
567
+ * By default, empty comment lines are left empty,
568
+ * lines consisting of a single space are replaced by `#`,
569
+ * and all other lines are prefixed with a `#`.
570
+ */
575
571
  commentString?: (comment: string) => string;
576
572
  /**
577
- * The default type of string literal used to stringify implicit key values.
578
- * Output may use other types if required to fully represent the value.
579
- *
580
- * If `null`, the value of `defaultStringType` is used.
581
- *
582
- * Default: `null`
583
- */
573
+ * The default type of string literal used to stringify implicit key values.
574
+ * Output may use other types if required to fully represent the value.
575
+ *
576
+ * If `null`, the value of `defaultStringType` is used.
577
+ *
578
+ * Default: `null`
579
+ */
584
580
  defaultKeyType?: Scalar.Type | null;
585
581
  /**
586
- * The default type of string literal used to stringify values in general.
587
- * Output may use other types if required to fully represent the value.
588
- *
589
- * Default: `'PLAIN'`
590
- */
582
+ * The default type of string literal used to stringify values in general.
583
+ * Output may use other types if required to fully represent the value.
584
+ *
585
+ * Default: `'PLAIN'`
586
+ */
591
587
  defaultStringType?: Scalar.Type;
592
588
  /**
593
- * Include directives in the output.
594
- *
595
- * - If `true`, at least the document-start marker `---` is always included.
596
- * This does not force the `%YAML` directive to be included. To do that,
597
- * set `doc.directives.yaml.explicit = true`.
598
- * - If `false`, no directives or marker is ever included. If using the `%TAG`
599
- * directive, you are expected to include it manually in the stream before
600
- * its use.
601
- * - If `null`, directives and marker may be included if required.
602
- *
603
- * Default: `null`
604
- */
589
+ * Include directives in the output.
590
+ *
591
+ * - If `true`, at least the document-start marker `---` is always included.
592
+ * This does not force the `%YAML` directive to be included. To do that,
593
+ * set `doc.directives.yaml.explicit = true`.
594
+ * - If `false`, no directives or marker is ever included. If using the `%TAG`
595
+ * directive, you are expected to include it manually in the stream before
596
+ * its use.
597
+ * - If `null`, directives and marker may be included if required.
598
+ *
599
+ * Default: `null`
600
+ */
605
601
  directives?: boolean | null;
606
602
  /**
607
- * Restrict double-quoted strings to use JSON-compatible syntax.
608
- *
609
- * Default: `false`
610
- */
603
+ * Restrict double-quoted strings to use JSON-compatible syntax.
604
+ *
605
+ * Default: `false`
606
+ */
611
607
  doubleQuotedAsJSON?: boolean;
612
608
  /**
613
- * Minimum length for double-quoted strings to use multiple lines to
614
- * represent the value. Ignored if `doubleQuotedAsJSON` is set.
615
- *
616
- * Default: `40`
617
- */
609
+ * Minimum length for double-quoted strings to use multiple lines to
610
+ * represent the value. Ignored if `doubleQuotedAsJSON` is set.
611
+ *
612
+ * Default: `40`
613
+ */
618
614
  doubleQuotedMinMultiLineLength?: number;
619
615
  /**
620
- * String representation for `false`.
621
- * With the core schema, use `'false'`, `'False'`, or `'FALSE'`.
622
- *
623
- * Default: `'false'`
624
- */
616
+ * String representation for `false`.
617
+ * With the core schema, use `'false'`, `'False'`, or `'FALSE'`.
618
+ *
619
+ * Default: `'false'`
620
+ */
625
621
  falseStr?: string;
626
622
  /**
627
- * When true, a single space of padding will be added inside the delimiters
628
- * of non-empty single-line flow collections.
629
- *
630
- * Default: `true`
631
- */
623
+ * When true, a single space of padding will be added inside the delimiters
624
+ * of non-empty single-line flow collections.
625
+ *
626
+ * Default: `true`
627
+ */
632
628
  flowCollectionPadding?: boolean;
633
629
  /**
634
- * The number of spaces to use when indenting code.
635
- *
636
- * Default: `2`
637
- */
630
+ * The number of spaces to use when indenting code.
631
+ *
632
+ * Default: `2`
633
+ */
638
634
  indent?: number;
639
635
  /**
640
- * Whether block sequences should be indented.
641
- *
642
- * Default: `true`
643
- */
636
+ * Whether block sequences should be indented.
637
+ *
638
+ * Default: `true`
639
+ */
644
640
  indentSeq?: boolean;
645
641
  /**
646
- * Maximum line width (set to `0` to disable folding).
647
- *
648
- * This is a soft limit, as only double-quoted semantics allow for inserting
649
- * a line break in the middle of a word, as well as being influenced by the
650
- * `minContentWidth` option.
651
- *
652
- * Default: `80`
653
- */
642
+ * Maximum line width (set to `0` to disable folding).
643
+ *
644
+ * This is a soft limit, as only double-quoted semantics allow for inserting
645
+ * a line break in the middle of a word, as well as being influenced by the
646
+ * `minContentWidth` option.
647
+ *
648
+ * Default: `80`
649
+ */
654
650
  lineWidth?: number;
655
651
  /**
656
- * Minimum line width for highly-indented content (set to `0` to disable).
657
- *
658
- * Default: `20`
659
- */
652
+ * Minimum line width for highly-indented content (set to `0` to disable).
653
+ *
654
+ * Default: `20`
655
+ */
660
656
  minContentWidth?: number;
661
657
  /**
662
- * String representation for `null`.
663
- * With the core schema, use `'null'`, `'Null'`, `'NULL'`, `'~'`, or an empty
664
- * string `''`.
665
- *
666
- * Default: `'null'`
667
- */
658
+ * String representation for `null`.
659
+ * With the core schema, use `'null'`, `'Null'`, `'NULL'`, `'~'`, or an empty
660
+ * string `''`.
661
+ *
662
+ * Default: `'null'`
663
+ */
668
664
  nullStr?: string;
669
665
  /**
670
- * Require keys to be scalars and to use implicit rather than explicit notation.
671
- *
672
- * Default: `false`
673
- */
666
+ * Require keys to be scalars and to use implicit rather than explicit notation.
667
+ *
668
+ * Default: `false`
669
+ */
674
670
  simpleKeys?: boolean;
675
671
  /**
676
- * Use 'single quote' rather than "double quote" where applicable.
677
- * Set to `false` to disable single quotes completely.
678
- *
679
- * Default: `null`
680
- */
672
+ * Use 'single quote' rather than "double quote" where applicable.
673
+ * Set to `false` to disable single quotes completely.
674
+ *
675
+ * Default: `null`
676
+ */
681
677
  singleQuote?: boolean | null;
682
678
  /**
683
- * When stringifying a map or a set, sort the entries.
684
- * If `true`, sort by comparing key values with `<`.
685
- *
686
- * Default: `false`
687
- */
679
+ * When stringifying a map or a set, sort the entries.
680
+ * If `true`, sort by comparing key values with `<`.
681
+ *
682
+ * Default: `false`
683
+ */
688
684
  sortMapEntries?: boolean | ((a: Pair, b: Pair) => number);
689
685
  /**
690
- * Add a trailing comma after the last entry in a flow map or flow sequence that's split across multiple lines.
691
- *
692
- * Default: `'false'`
693
- */
686
+ * Add a trailing comma after the last entry in a flow map or flow sequence that's split across multiple lines.
687
+ *
688
+ * Default: `'false'`
689
+ */
694
690
  trailingComma?: boolean;
695
691
  /**
696
- * String representation for `true`.
697
- * With the core schema, use `'true'`, `'True'`, or `'TRUE'`.
698
- *
699
- * Default: `'true'`
700
- */
692
+ * String representation for `true`.
693
+ * With the core schema, use `'true'`, `'True'`, or `'TRUE'`.
694
+ *
695
+ * Default: `'true'`
696
+ */
701
697
  trueStr?: string;
702
698
  /**
703
- * The anchor used by an alias must be defined before the alias node. As it's
704
- * possible for the document to be modified manually, the order may be
705
- * verified during stringification.
706
- *
707
- * Default: `'true'`
708
- */
699
+ * The anchor used by an alias must be defined before the alias node. As it's
700
+ * possible for the document to be modified manually, the order may be
701
+ * verified during stringification.
702
+ *
703
+ * Default: `'true'`
704
+ */
709
705
  verifyAliasOrder?: boolean;
710
706
  };
711
707
  //#endregion
@@ -717,15 +713,7 @@ declare class Schema {
717
713
  name: string;
718
714
  tags: Array<CollectionTag | ScalarTag>;
719
715
  toStringOptions: Readonly<ToStringOptions> | null;
720
- constructor({
721
- compat,
722
- customTags,
723
- mapKey,
724
- merge,
725
- resolveKnownTags,
726
- schema,
727
- toStringDefaults
728
- }: SchemaOptions);
716
+ constructor({ compat, customTags, mapKey, merge, resolveKnownTags, schema, toStringDefaults }: SchemaOptions);
729
717
  clone(): Schema;
730
718
  }
731
719
  //#endregion
@@ -747,19 +735,19 @@ declare class YAMLSeq<T extends Primitive | Node | Pair = Primitive | Node | Pai
747
735
  /** An optional anchor on this collection. Used by alias nodes. */
748
736
  anchor?: string;
749
737
  /**
750
- * If true, stringify this and all child nodes using flow rather than
751
- * block styles.
752
- */
738
+ * If true, stringify this and all child nodes using flow rather than
739
+ * block styles.
740
+ */
753
741
  flow?: boolean;
754
742
  /** A comment on or immediately after this collection. */
755
743
  comment?: string | null;
756
744
  /** A comment before this collection. */
757
745
  commentBefore?: string | null;
758
746
  /**
759
- * The `[start, value-end, node-end]` character offsets for
760
- * the part of the source parsed into this collection (undefined if not parsed).
761
- * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
762
- */
747
+ * The `[start, value-end, node-end]` character offsets for
748
+ * the part of the source parsed into this collection (undefined if not parsed).
749
+ * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
750
+ */
763
751
  range?: Range | null;
764
752
  /** A blank line before this collection and its commentBefore */
765
753
  spaceBefore?: boolean;
@@ -768,50 +756,50 @@ declare class YAMLSeq<T extends Primitive | Node | Pair = Primitive | Node | Pai
768
756
  /** A fully qualified tag, if required */
769
757
  tag?: string;
770
758
  /**
771
- * A generic collection factory method that can be extended
772
- * to other node classes that inherit from YAMLSeq
773
- */
759
+ * A generic collection factory method that can be extended
760
+ * to other node classes that inherit from YAMLSeq
761
+ */
774
762
  static create(nc: NodeCreator, obj: unknown): YAMLSeq;
775
763
  constructor(schema: Schema, elements?: Array<T | NodeOf<T>>);
776
764
  get size(): number;
777
765
  /**
778
- * Create a copy of this collection.
779
- *
780
- * @param schema - If defined, overwrites the original's schema
781
- */
766
+ * Create a copy of this collection.
767
+ *
768
+ * @param schema - If defined, overwrites the original's schema
769
+ */
782
770
  clone(schema?: Schema): this;
783
771
  /**
784
- * Change all elements within a range of indices in this sequence to a static value.
785
- *
786
- * Non-node values are converted to Node values.
787
- */
772
+ * Change all elements within a range of indices in this sequence to a static value.
773
+ *
774
+ * Non-node values are converted to Node values.
775
+ */
788
776
  fill(value: T | NodeOf<T>, start?: number, end?: number): this;
789
777
  /** @private */
790
778
  _push(item: NodeOf<T>): void;
791
779
  /**
792
- * Append new elements to this sequence, and return its new length.
793
- *
794
- * Non-node values are converted to Node values.
795
- */
780
+ * Append new elements to this sequence, and return its new length.
781
+ *
782
+ * Non-node values are converted to Node values.
783
+ */
796
784
  push(...values: Array<T | NodeOf<T>>): number;
797
785
  /**
798
- * Set a value in this sequence.
799
- *
800
- * Non-node values are converted to Node values.
801
- */
786
+ * Set a value in this sequence.
787
+ *
788
+ * Non-node values are converted to Node values.
789
+ */
802
790
  set(idx: number, value: T | NodeOf<T>, options?: Omit<CreateNodeOptions, "aliasDuplicateObjects">): void;
803
791
  /**
804
- * Changes the contents of this sequence by removing or replacing existing elements
805
- * and/or adding new elements in place.
806
- *
807
- * Non-node values are converted to Node values.
808
- */
792
+ * Changes the contents of this sequence by removing or replacing existing elements
793
+ * and/or adding new elements in place.
794
+ *
795
+ * Non-node values are converted to Node values.
796
+ */
809
797
  splice(start: number, deleteCount?: number, ...values: Array<T | NodeOf<T>>): NodeOf<T>[];
810
798
  /**
811
- * Prepend new elements to this sequence, and return its new length.
812
- *
813
- * Non-node values are converted to Node values.
814
- */
799
+ * Prepend new elements to this sequence, and return its new length.
800
+ *
801
+ * Non-node values are converted to Node values.
802
+ */
815
803
  unshift(...values: Array<T | NodeOf<T>>): number;
816
804
  /** A plain JavaScript representation of this node. */
817
805
  toJS(doc: Document<DocValue, boolean>, ctx?: ToJSContext): any[];
@@ -833,24 +821,24 @@ declare const string: ScalarTag;
833
821
  //#endregion
834
822
  //#region src/stringify/foldFlowLines.d.ts
835
823
  /**
836
- * `'block'` prevents more-indented lines from being folded;
837
- * `'quoted'` allows for `\` escapes, including escaped newlines
838
- */
824
+ * `'block'` prevents more-indented lines from being folded;
825
+ * `'quoted'` allows for `\` escapes, including escaped newlines
826
+ */
839
827
  type FoldMode = "flow" | "block" | "quoted";
840
828
  interface FoldOptions {
841
829
  /**
842
- * Accounts for leading contents on the first line, defaulting to
843
- * `indent.length`
844
- */
830
+ * Accounts for leading contents on the first line, defaulting to
831
+ * `indent.length`
832
+ */
845
833
  indentAtStart?: number;
846
834
  /** Default: `80` */
847
835
  lineWidth?: number;
848
836
  /**
849
- * Allow highly indented lines to stretch the line width or indent content
850
- * from the start.
851
- *
852
- * Default: `20`
853
- */
837
+ * Allow highly indented lines to stretch the line width or indent content
838
+ * from the start.
839
+ *
840
+ * Default: `20`
841
+ */
854
842
  minContentWidth?: number;
855
843
  /** Called once if the text is folded */
856
844
  onFold?: () => void;
@@ -858,25 +846,14 @@ interface FoldOptions {
858
846
  onOverflow?: () => void;
859
847
  }
860
848
  /**
861
- * Tries to keep input at up to `lineWidth` characters, splitting only on spaces
862
- * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
863
- * terminated with `\n` and started with `indent`.
864
- */
865
- declare function foldFlowLines(text: string, indent: string, mode?: FoldMode, {
866
- indentAtStart,
867
- lineWidth,
868
- minContentWidth,
869
- onFold,
870
- onOverflow
871
- }?: FoldOptions): string;
849
+ * Tries to keep input at up to `lineWidth` characters, splitting only on spaces
850
+ * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
851
+ * terminated with `\n` and started with `indent`.
852
+ */
853
+ declare function foldFlowLines(text: string, indent: string, mode?: FoldMode, { indentAtStart, lineWidth, minContentWidth, onFold, onOverflow }?: FoldOptions): string;
872
854
  //#endregion
873
855
  //#region src/stringify/stringifyNumber.d.ts
874
- declare function stringifyNumber({
875
- format,
876
- minFractionDigits,
877
- tag,
878
- value
879
- }: Scalar): string;
856
+ declare function stringifyNumber({ format, minFractionDigits, source, tag, value }: Scalar, version?: "1.1" | "1.2"): string;
880
857
  //#endregion
881
858
  //#region src/stringify/stringifyString.d.ts
882
859
  interface StringifyScalar {
@@ -903,10 +880,10 @@ declare class YAMLSet<T extends Primitive | Node = Primitive | Node> implements
903
880
  /** A comment before this set. */
904
881
  commentBefore?: string | null;
905
882
  /**
906
- * The `[start, value-end, node-end]` character offsets for
907
- * the part of the source parsed into this set (undefined if not parsed).
908
- * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
909
- */
883
+ * The `[start, value-end, node-end]` character offsets for
884
+ * the part of the source parsed into this set (undefined if not parsed).
885
+ * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
886
+ */
910
887
  range?: Range | null;
911
888
  /** A blank line before this set and its commentBefore */
912
889
  spaceBefore?: boolean;
@@ -916,26 +893,26 @@ declare class YAMLSet<T extends Primitive | Node = Primitive | Node> implements
916
893
  get size(): number;
917
894
  add(value: T | NodeOf<T>, options?: Omit<CreateNodeOptions, "aliasDuplicateObjects">): this;
918
895
  /**
919
- * Create a copy of this set.
920
- *
921
- * @param schema - If defined, overwrites the original's schema
922
- */
896
+ * Create a copy of this set.
897
+ *
898
+ * @param schema - If defined, overwrites the original's schema
899
+ */
923
900
  clone(schema?: Schema): this;
924
901
  /**
925
- * Remove `value` from the set.
926
- * @returns `true` if the item was found and removed.
927
- */
902
+ * Remove `value` from the set.
903
+ * @returns `true` if the item was found and removed.
904
+ */
928
905
  delete(value: T | NodeOf<T>): boolean;
929
906
  /** Return the node matching `value`, if the set includes it. */
930
907
  get(value: T | NodeOf<T>): NodeOf<T> | undefined;
931
908
  /** Check if the set includes `value`. */
932
909
  has(value: T | NodeOf<T>): boolean;
933
910
  /**
934
- * Return the internal Map key matching `value`, or `undefined` if not found.
935
- *
936
- * @param allowMissing - If `true`, a key is always returned,
937
- * even if the value is not in the set.
938
- */
911
+ * Return the internal Map key matching `value`, or `undefined` if not found.
912
+ *
913
+ * @param allowMissing - If `true`, a key is always returned,
914
+ * even if the value is not in the set.
915
+ */
939
916
  keyOf(value: T | NodeOf<T>, allowMissing?: boolean): unknown;
940
917
  /** A plain JavaScript representation of this set. */
941
918
  toJS(doc: Document<DocValue, boolean>, ctx?: ToJSContext): Set<any>;
@@ -958,11 +935,11 @@ interface NodeBase {
958
935
  /** A comment before this */
959
936
  commentBefore?: string | null;
960
937
  /**
961
- * The `[start, value-end, node-end]` character offsets for the part of the
962
- * source parsed into this node (undefined if not parsed). The `value-end`
963
- * and `node-end` positions are themselves not included in their respective
964
- * ranges.
965
- */
938
+ * The `[start, value-end, node-end]` character offsets for the part of the
939
+ * source parsed into this node (undefined if not parsed). The `value-end`
940
+ * and `node-end` positions are themselves not included in their respective
941
+ * ranges.
942
+ */
966
943
  range?: Range | null;
967
944
  /** A blank line before this node and its commentBefore */
968
945
  spaceBefore?: boolean;
@@ -971,10 +948,10 @@ interface NodeBase {
971
948
  /** A fully qualified tag, if required */
972
949
  tag?: string;
973
950
  /**
974
- * Create a copy of this node.
975
- *
976
- * @param schema - If defined, overwrites the original's schema for cloned collections.
977
- */
951
+ * Create a copy of this node.
952
+ *
953
+ * @param schema - If defined, overwrites the original's schema for cloned collections.
954
+ */
978
955
  clone(schema?: Schema): this;
979
956
  /** A plain JavaScript representation of this node. */
980
957
  toJS(doc: Document<DocValue, boolean>, opt?: ToJSContext): any;
@@ -994,9 +971,9 @@ interface CollectionBase extends NodeBase {
994
971
  //#endregion
995
972
  //#region src/parse/cst-scalar.d.ts
996
973
  /**
997
- * If `token` is a CST flow or block scalar, determine its string value and a few other attributes.
998
- * Otherwise, return `null`.
999
- */
974
+ * If `token` is a CST flow or block scalar, determine its string value and a few other attributes.
975
+ * Otherwise, return `null`.
976
+ */
1000
977
  declare function resolveAsScalar(token: FlowScalar | BlockScalar, strict?: boolean, onError?: (offset: number, code: ErrorCode, message: string) => void): {
1001
978
  value: string;
1002
979
  type: Scalar.Type | null;
@@ -1010,19 +987,19 @@ declare function resolveAsScalar(token: Token | null | undefined, strict?: boole
1010
987
  range: Range;
1011
988
  } | null;
1012
989
  /**
1013
- * Create a new scalar token with `value`
1014
- *
1015
- * Values that represent an actual string but may be parsed as a different type should use a `type` other than `'PLAIN'`,
1016
- * as this function does not support any schema operations and won't check for such conflicts.
1017
- *
1018
- * @param value The string representation of the value, which will have its content properly indented.
1019
- * @param context.end Comments and whitespace after the end of the value, or after the block scalar header. If undefined, a newline will be added.
1020
- * @param context.implicitKey Being within an implicit key may affect the resolved type of the token's value.
1021
- * @param context.indent The indent level of the token.
1022
- * @param context.inFlow Is this scalar within a flow collection? This may affect the resolved type of the token's value.
1023
- * @param context.offset The offset position of the token.
1024
- * @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
1025
- */
990
+ * Create a new scalar token with `value`
991
+ *
992
+ * Values that represent an actual string but may be parsed as a different type should use a `type` other than `'PLAIN'`,
993
+ * as this function does not support any schema operations and won't check for such conflicts.
994
+ *
995
+ * @param value The string representation of the value, which will have its content properly indented.
996
+ * @param context.end Comments and whitespace after the end of the value, or after the block scalar header. If undefined, a newline will be added.
997
+ * @param context.implicitKey Being within an implicit key may affect the resolved type of the token's value.
998
+ * @param context.indent The indent level of the token.
999
+ * @param context.inFlow Is this scalar within a flow collection? This may affect the resolved type of the token's value.
1000
+ * @param context.offset The offset position of the token.
1001
+ * @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
1002
+ */
1026
1003
  declare function createScalarToken(value: string, context: {
1027
1004
  end?: SourceToken[];
1028
1005
  implicitKey?: boolean;
@@ -1032,21 +1009,21 @@ declare function createScalarToken(value: string, context: {
1032
1009
  type?: Scalar.Type;
1033
1010
  }): BlockScalar | FlowScalar;
1034
1011
  /**
1035
- * Set the value of `token` to the given string `value`, overwriting any previous contents and type that it may have.
1036
- *
1037
- * Best efforts are made to retain any comments previously associated with the `token`,
1038
- * though all contents within a collection's `items` will be overwritten.
1039
- *
1040
- * Values that represent an actual string but may be parsed as a different type should use a `type` other than `'PLAIN'`,
1041
- * as this function does not support any schema operations and won't check for such conflicts.
1042
- *
1043
- * @param token Any token. If it does not include an `indent` value, the value will be stringified as if it were an implicit key.
1044
- * @param value The string representation of the value, which will have its content properly indented.
1045
- * @param context.afterKey In most cases, values after a key should have an additional level of indentation.
1046
- * @param context.implicitKey Being within an implicit key may affect the resolved type of the token's value.
1047
- * @param context.inFlow Being within a flow collection may affect the resolved type of the token's value.
1048
- * @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
1049
- */
1012
+ * Set the value of `token` to the given string `value`, overwriting any previous contents and type that it may have.
1013
+ *
1014
+ * Best efforts are made to retain any comments previously associated with the `token`,
1015
+ * though all contents within a collection's `items` will be overwritten.
1016
+ *
1017
+ * Values that represent an actual string but may be parsed as a different type should use a `type` other than `'PLAIN'`,
1018
+ * as this function does not support any schema operations and won't check for such conflicts.
1019
+ *
1020
+ * @param token Any token. If it does not include an `indent` value, the value will be stringified as if it were an implicit key.
1021
+ * @param value The string representation of the value, which will have its content properly indented.
1022
+ * @param context.afterKey In most cases, values after a key should have an additional level of indentation.
1023
+ * @param context.implicitKey Being within an implicit key may affect the resolved type of the token's value.
1024
+ * @param context.inFlow Being within a flow collection may affect the resolved type of the token's value.
1025
+ * @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
1026
+ */
1050
1027
  declare function setScalarValue(token: Token, value: string, context?: {
1051
1028
  afterKey?: boolean;
1052
1029
  implicitKey?: boolean;
@@ -1056,55 +1033,59 @@ declare function setScalarValue(token: Token, value: string, context?: {
1056
1033
  //#endregion
1057
1034
  //#region src/parse/cst-stringify.d.ts
1058
1035
  /**
1059
- * Stringify a CST document, token, or collection item
1060
- *
1061
- * Fair warning: This applies no validation whatsoever, and
1062
- * simply concatenates the sources in their logical order.
1063
- */
1036
+ * Stringify a CST document, token, or collection item
1037
+ *
1038
+ * Fair warning: This applies no validation whatsoever, and
1039
+ * simply concatenates the sources in their logical order.
1040
+ */
1064
1041
  declare const stringify: (cst: Token | CollectionItem) => string;
1065
1042
  //#endregion
1066
1043
  //#region src/parse/cst-visit.d.ts
1067
1044
  type VisitPath = readonly ["key" | "value", number][];
1068
1045
  type Visitor = (item: CollectionItem, path: VisitPath) => number | symbol | Visitor | void;
1069
1046
  /**
1070
- * Apply a visitor to a CST document or item.
1071
- *
1072
- * Walks through the tree (depth-first) starting from the root, calling a
1073
- * `visitor` function with two arguments when entering each item:
1074
- * - `item`: The current item, which included the following members:
1075
- * - `start: SourceToken[]` – Source tokens before the key or value,
1076
- * possibly including its anchor or tag.
1077
- * - `key?: Token | null` – Set for pair values. May then be `null`, if
1078
- * the key before the `:` separator is empty.
1079
- * - `sep?: SourceToken[]` – Source tokens between the key and the value,
1080
- * which should include the `:` map value indicator if `value` is set.
1081
- * - `value?: Token` – The value of a sequence item, or of a map pair.
1082
- * - `path`: The steps from the root to the current node, as an array of
1083
- * `['key' | 'value', number]` tuples.
1084
- *
1085
- * The return value of the visitor may be used to control the traversal:
1086
- * - `undefined` (default): Do nothing and continue
1087
- * - `visit.SKIP`: Do not visit the children of this token, continue with
1088
- * next sibling
1089
- * - `visit.BREAK`: Terminate traversal completely
1090
- * - `visit.REMOVE`: Remove the current item, then continue with the next one
1091
- * - `number`: Set the index of the next step. This is useful especially if
1092
- * the index of the current token has changed.
1093
- * - `function`: Define the next visitor for this item. After the original
1094
- * visitor is called on item entry, next visitors are called after handling
1095
- * a non-empty `key` and when exiting the item.
1096
- */
1047
+ * Apply a visitor to a CST document or item.
1048
+ *
1049
+ * Walks through the tree (depth-first) starting from the root, calling a
1050
+ * `visitor` function with two arguments when entering each item:
1051
+ * - `item`: The current item, which included the following members:
1052
+ * - `start: SourceToken[]` – Source tokens before the key or value,
1053
+ * possibly including its anchor or tag.
1054
+ * - `key?: Token | null` – Set for pair values. May then be `null`, if
1055
+ * the key before the `:` separator is empty.
1056
+ * - `sep?: SourceToken[]` – Source tokens between the key and the value,
1057
+ * which should include the `:` map value indicator if `value` is set.
1058
+ * - `value?: Token` – The value of a sequence item, or of a map pair.
1059
+ * - `path`: The steps from the root to the current node, as an array of
1060
+ * `['key' | 'value', number]` tuples.
1061
+ *
1062
+ * The return value of the visitor may be used to control the traversal:
1063
+ * - `undefined` (default): Do nothing and continue
1064
+ * - `visit.SKIP`: Do not visit the children of this token, continue with
1065
+ * next sibling
1066
+ * - `visit.BREAK`: Terminate traversal completely
1067
+ * - `visit.REMOVE`: Remove the current item, then continue with the next one
1068
+ * - `number`: Set the index of the next step. This is useful especially if
1069
+ * the index of the current token has changed.
1070
+ * - `function`: Define the next visitor for this item. After the original
1071
+ * visitor is called on item entry, next visitors are called after handling
1072
+ * a non-empty `key` and when exiting the item.
1073
+ */
1097
1074
  declare const visit: {
1098
- (cst: Document$1 | CollectionItem, visitor: Visitor): void; /** Terminate visit traversal completely */
1099
- BREAK: symbol; /** Do not visit the children of the current item */
1100
- SKIP: symbol; /** Remove the current item */
1101
- REMOVE: symbol; /** Find the item at `path` from `cst` as the root */
1075
+ (cst: Document$1 | CollectionItem, visitor: Visitor): void;
1076
+ /** Terminate visit traversal completely */
1077
+ BREAK: symbol;
1078
+ /** Do not visit the children of the current item */
1079
+ SKIP: symbol;
1080
+ /** Remove the current item */
1081
+ REMOVE: symbol;
1082
+ /** Find the item at `path` from `cst` as the root */
1102
1083
  itemAtPath(cst: Document$1 | CollectionItem, path: VisitPath): CollectionItem | undefined;
1103
1084
  /**
1104
- * Get the immediate parent collection of the item at `path` from `cst` as the root.
1105
- *
1106
- * Throws an error if the collection is not found, which should never happen if the item itself exists.
1107
- */
1085
+ * Get the immediate parent collection of the item at `path` from `cst` as the root.
1086
+ *
1087
+ * Throws an error if the collection is not found, which should never happen if the item itself exists.
1088
+ */
1108
1089
  parentCollection(cst: Document$1 | CollectionItem, path: VisitPath): BlockMap | BlockSequence | FlowCollection;
1109
1090
  };
1110
1091
  declare namespace cst_d_exports {
@@ -1225,10 +1206,10 @@ declare class Alias implements NodeBase {
1225
1206
  /** A comment before this node. */
1226
1207
  commentBefore?: string | null;
1227
1208
  /**
1228
- * The `[start, value-end, node-end]` character offsets for
1229
- * the part of the source parsed into this node (undefined if not parsed).
1230
- * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
1231
- */
1209
+ * The `[start, value-end, node-end]` character offsets for
1210
+ * the part of the source parsed into this node (undefined if not parsed).
1211
+ * The `value-end` and `node-end` positions are themselves not included in their respective ranges.
1212
+ */
1232
1213
  range?: Range | null;
1233
1214
  /** A blank line before this node and its commentBefore */
1234
1215
  spaceBefore?: boolean;
@@ -1241,9 +1222,9 @@ declare class Alias implements NodeBase {
1241
1222
  /** Create a copy of this node. */
1242
1223
  clone(): this;
1243
1224
  /**
1244
- * Resolve the value of this alias within `doc`, finding the last
1245
- * instance of the `source` anchor before this node.
1246
- */
1225
+ * Resolve the value of this alias within `doc`, finding the last
1226
+ * instance of the `source` anchor before this node.
1227
+ */
1247
1228
  resolve(doc: Document, ctx?: ToJSContext): Scalar | YAMLMap | YAMLSeq | YAMLSet | undefined;
1248
1229
  /** A plain JavaScript representation of the resolved value of this alias. */
1249
1230
  toJS(doc: Document<DocValue, boolean>, ctx?: ToJSContext): any;
@@ -1272,68 +1253,68 @@ declare class Document<Value extends DocValue = DocValue, Strict extends boolean
1272
1253
  errors: YAMLError[];
1273
1254
  options: Required<Omit<ParseOptions & DocumentOptions, "_directives" | "lineCounter" | "version">>;
1274
1255
  /**
1275
- * The `[start, value-end, node-end]` character offsets for the part of the
1276
- * source parsed into this document (undefined if not parsed). The `value-end`
1277
- * and `node-end` positions are themselves not included in their respective
1278
- * ranges.
1279
- */
1256
+ * The `[start, value-end, node-end]` character offsets for the part of the
1257
+ * source parsed into this document (undefined if not parsed). The `value-end`
1258
+ * and `node-end` positions are themselves not included in their respective
1259
+ * ranges.
1260
+ */
1280
1261
  range?: Range;
1281
1262
  /** The schema used with the document. Use `setSchema()` to change. */
1282
1263
  schema: Schema;
1283
1264
  /** Warnings encountered during parsing. */
1284
1265
  warnings: YAMLWarning[];
1285
1266
  /**
1286
- * @param value - The initial value for the document, which will be wrapped
1287
- * in a Node container.
1288
- */
1267
+ * @param value - The initial value for the document, which will be wrapped
1268
+ * in a Node container.
1269
+ */
1289
1270
  constructor(value?: any, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions);
1290
1271
  constructor(value: any, replacer: null | Replacer, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions);
1291
1272
  /**
1292
- * Create a deep copy of this Document and its value.
1293
- *
1294
- * Custom Node values that inherit from `Object` still refer to their original instances.
1295
- */
1273
+ * Create a deep copy of this Document and its value.
1274
+ *
1275
+ * Custom Node values that inherit from `Object` still refer to their original instances.
1276
+ */
1296
1277
  clone(): Document<Value, Strict>;
1297
1278
  /**
1298
- * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
1299
- *
1300
- * If `node` already has an anchor, `name` is ignored.
1301
- * Otherwise, the `node.anchor` value will be set to `name`,
1302
- * or if an anchor with that name is already present in the document,
1303
- * `name` will be used as a prefix for a new unique anchor.
1304
- * If `name` is undefined, the generated anchor will use 'a' as a prefix.
1305
- */
1279
+ * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
1280
+ *
1281
+ * If `node` already has an anchor, `name` is ignored.
1282
+ * Otherwise, the `node.anchor` value will be set to `name`,
1283
+ * or if an anchor with that name is already present in the document,
1284
+ * `name` will be used as a prefix for a new unique anchor.
1285
+ * If `name` is undefined, the generated anchor will use 'a' as a prefix.
1286
+ */
1306
1287
  createAlias(node: Strict extends true ? DocValue : Node, name?: string): Alias;
1307
1288
  /**
1308
- * Convert any value into a `Node` using the current schema, recursively
1309
- * turning objects into collections.
1310
- */
1289
+ * Convert any value into a `Node` using the current schema, recursively
1290
+ * turning objects into collections.
1291
+ */
1311
1292
  createNode<T = unknown>(value: T, options?: CreateNodeOptions): NodeType<T>;
1312
1293
  createNode<T = unknown>(value: T, replacer: Replacer | CreateNodeOptions | null, options?: CreateNodeOptions): NodeType<T>;
1313
1294
  /**
1314
- * Convert a key and a value into a `Pair` using the current schema,
1315
- * recursively wrapping all values as `Scalar` or `Collection` nodes.
1316
- */
1295
+ * Convert a key and a value into a `Pair` using the current schema,
1296
+ * recursively wrapping all values as `Scalar` or `Collection` nodes.
1297
+ */
1317
1298
  createPair<K = unknown, V = unknown>(key: K, value: V, options?: CreateNodeOptions): Pair<K extends Primitive | Node ? K : Node, V extends Primitive | Node ? V : Node>;
1318
1299
  /**
1319
- * Returns item at `key`, or `undefined` if not found.
1320
- */
1300
+ * Returns item at `key`, or `undefined` if not found.
1301
+ */
1321
1302
  get(key: any): Strict extends true ? Node | Pair | null | undefined : any;
1322
1303
  /**
1323
- * Returns pair at `key`, or `undefined` if not found.
1324
- */
1304
+ * Returns pair at `key`, or `undefined` if not found.
1305
+ */
1325
1306
  getPair(key: any): Strict extends true ? Pair | undefined : any;
1326
1307
  /**
1327
- * Sets a value in this document's top-level collection. For `!!set`, `value` is ignored.
1328
- */
1308
+ * Sets a value in this document's top-level collection. For `!!set`, `value` is ignored.
1309
+ */
1329
1310
  set(key: any, value: any): void;
1330
1311
  /**
1331
- * Change the YAML version and schema used by the document.
1332
- * A `null` version disables support for directives, explicit tags, anchors, and aliases.
1333
- * It also requires the `schema` option to be given as a `Schema` instance value.
1334
- *
1335
- * Overrides all previously set schema options.
1336
- */
1312
+ * Change the YAML version and schema used by the document.
1313
+ * A `null` version disables support for directives, explicit tags, anchors, and aliases.
1314
+ * It also requires the `schema` option to be given as a `Schema` instance value.
1315
+ *
1316
+ * Overrides all previously set schema options.
1317
+ */
1337
1318
  setSchema(version: "1.1" | "1.2" | "next" | null, options?: SchemaOptions): void;
1338
1319
  /** A plain JavaScript representation of the document `value`. */
1339
1320
  toJS(opt?: ToJSOptions): any;
@@ -1353,42 +1334,42 @@ declare class Directives {
1353
1334
  };
1354
1335
  tags: Record<string, string>;
1355
1336
  /**
1356
- * The directives-end/doc-start marker `---`. If `null`, a marker may still be
1357
- * included in the document's stringified representation.
1358
- */
1337
+ * The directives-end/doc-start marker `---`. If `null`, a marker may still be
1338
+ * included in the document's stringified representation.
1339
+ */
1359
1340
  docStart: true | null;
1360
1341
  /** The doc-end marker `...`. */
1361
1342
  docEnd: boolean;
1362
1343
  /**
1363
- * Used when parsing YAML 1.1, where:
1364
- * > If the document specifies no directives, it is parsed using the same
1365
- * > settings as the previous document. If the document does specify any
1366
- * > directives, all directives of previous documents, if any, are ignored.
1367
- */
1344
+ * Used when parsing YAML 1.1, where:
1345
+ * > If the document specifies no directives, it is parsed using the same
1346
+ * > settings as the previous document. If the document does specify any
1347
+ * > directives, all directives of previous documents, if any, are ignored.
1348
+ */
1368
1349
  private atNextDocument?;
1369
1350
  constructor(yaml?: Directives["yaml"], tags?: Directives["tags"]);
1370
1351
  clone(): Directives;
1371
1352
  /**
1372
- * During parsing, get a Directives instance for the current document and
1373
- * update the stream state according to the current version's spec.
1374
- */
1353
+ * During parsing, get a Directives instance for the current document and
1354
+ * update the stream state according to the current version's spec.
1355
+ */
1375
1356
  atDocument(): Directives;
1376
1357
  /**
1377
- * @param onError - May be called even if the action was successful
1378
- * @returns `true` on success
1379
- */
1358
+ * @param onError - May be called even if the action was successful
1359
+ * @returns `true` on success
1360
+ */
1380
1361
  add(line: string, onError: (offset: number, message: string, warning?: boolean) => void): boolean;
1381
1362
  /**
1382
- * Resolves a tag, matching handles to those defined in %TAG directives.
1383
- *
1384
- * @returns Resolved tag, which may also be the non-specific tag `'!'` or a
1385
- * `'!local'` tag, or `null` if unresolvable.
1386
- */
1363
+ * Resolves a tag, matching handles to those defined in %TAG directives.
1364
+ *
1365
+ * @returns Resolved tag, which may also be the non-specific tag `'!'` or a
1366
+ * `'!local'` tag, or `null` if unresolvable.
1367
+ */
1387
1368
  tagName(source: string, onError: (message: string) => void): string | null;
1388
1369
  /**
1389
- * Given a fully resolved tag, returns its printable string form,
1390
- * taking into account current tag prefixes and defaults.
1391
- */
1370
+ * Given a fully resolved tag, returns its printable string form,
1371
+ * taking into account current tag prefixes and defaults.
1372
+ */
1392
1373
  tagString(tag: string): string;
1393
1374
  toString(doc?: Document): string;
1394
1375
  }