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.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,16 @@
1
- import { A as CollectionTag, C as DocumentOptions, D as ToStringOptions, E as ToJSOptions, F as Scalar, G as YAMLParseError, H as Reviver, K as YAMLWarning, L as ToJSContext, M as Pair, N as KeyArg, O as TagId, P as YAMLMap, R as StringifyContext, S as CreateNodeOptions, T as SchemaOptions, U as ErrorCode, W as YAMLError, a as Alias, c as Node, d as Range, f as YAMLSet, i as Replacer, j as ScalarTag, k as Tags, l as NodeBase, n as DocValue, o as Token, q as LineCounter, r as Document, s as cst_d_exports, t as Directives, u as Primitive, w as ParseOptions, x as Schema, y as YAMLSeq } from "./directives-DlYEVlkC.js";
2
-
1
+ import { A as CollectionTag, C as DocumentOptions, D as ToStringOptions, E as ToJSOptions, F as Scalar, G as YAMLParseError, H as Reviver, K as YAMLWarning, L as ToJSContext, M as Pair, N as KeyArg, O as TagId, P as YAMLMap, R as StringifyContext, S as CreateNodeOptions, T as SchemaOptions, U as ErrorCode, W as YAMLError, a as Alias, c as Node, d as Range, f as YAMLSet, i as Replacer, j as ScalarTag, k as Tags, l as NodeBase, n as DocValue, o as Token, q as LineCounter, r as Document, s as cst_d_exports, t as Directives, u as Primitive, w as ParseOptions, x as Schema, y as YAMLSeq } from "./directives-CGITitH5.js";
3
2
  //#region src/compose/composer.d.ts
4
3
  /**
5
- * Compose a stream of CST nodes into a stream of YAML Documents.
6
- *
7
- * ```ts
8
- * import { Composer, Parser } from 'yaml'
9
- *
10
- * const src: string = ...
11
- * const tokens = new Parser().parse(src)
12
- * const docs = new Composer().compose(tokens)
13
- * ```
14
- */
4
+ * Compose a stream of CST nodes into a stream of YAML Documents.
5
+ *
6
+ * ```ts
7
+ * import { Composer, Parser } from 'yaml'
8
+ *
9
+ * const src: string = ...
10
+ * const tokens = new Parser().parse(src)
11
+ * const docs = new Composer().compose(tokens)
12
+ * ```
13
+ */
15
14
  declare class Composer<Value extends DocValue = DocValue, Strict extends boolean = true> {
16
15
  private directives;
17
16
  private doc;
@@ -25,10 +24,10 @@ declare class Composer<Value extends DocValue = DocValue, Strict extends boolean
25
24
  private onError;
26
25
  private decorate;
27
26
  /**
28
- * Current stream status information.
29
- *
30
- * Mostly useful at the end of input for an empty stream.
31
- */
27
+ * Current stream status information.
28
+ *
29
+ * Mostly useful at the end of input for an empty stream.
30
+ */
32
31
  streamInfo(): {
33
32
  comment: string;
34
33
  directives: Directives;
@@ -36,20 +35,20 @@ declare class Composer<Value extends DocValue = DocValue, Strict extends boolean
36
35
  warnings: YAMLWarning[];
37
36
  };
38
37
  /**
39
- * Compose tokens into documents.
40
- *
41
- * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
42
- * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
43
- */
38
+ * Compose tokens into documents.
39
+ *
40
+ * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
41
+ * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
42
+ */
44
43
  compose(tokens: Iterable<Token>, forceDoc?: boolean, endOffset?: number): Document.Parsed<Value, Strict>[];
45
44
  /** Advance the composer by one CST token. */
46
45
  next(token: Token): void;
47
46
  /**
48
- * Call at end of input to handle any remaining document.
49
- *
50
- * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
51
- * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
52
- */
47
+ * Call at end of input to handle any remaining document.
48
+ *
49
+ * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
50
+ * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
51
+ */
53
52
  end(forceDoc?: boolean, endOffset?: number): Document.Parsed<Value, Strict>[];
54
53
  }
55
54
  //#endregion
@@ -61,47 +60,47 @@ declare const isNode: (node: unknown) => node is Node;
61
60
  //#endregion
62
61
  //#region src/parse/lexer.d.ts
63
62
  /**
64
- * Splits an input `source` string into lexical YAML tokens,
65
- * i.e. smaller strings that are easily identifiable by `tokens.tokenType()`.
66
- *
67
- * Lexing starts always in a "stream" context.
68
- *
69
- * In addition to slices of the original input, the following control characters
70
- * may also be emitted:
71
- *
72
- * - `\x02` (Start of Text): A document starts with the next token
73
- * - `\x18` (Cancel): Unexpected end of flow-mode (indicates an error)
74
- * - `\x1f` (Unit Separator): Next token is a scalar value
75
- * - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
76
- */
63
+ * Splits an input `source` string into lexical YAML tokens,
64
+ * i.e. smaller strings that are easily identifiable by `tokens.tokenType()`.
65
+ *
66
+ * Lexing starts always in a "stream" context.
67
+ *
68
+ * In addition to slices of the original input, the following control characters
69
+ * may also be emitted:
70
+ *
71
+ * - `\x02` (Start of Text): A document starts with the next token
72
+ * - `\x18` (Cancel): Unexpected end of flow-mode (indicates an error)
73
+ * - `\x1f` (Unit Separator): Next token is a scalar value
74
+ * - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
75
+ */
77
76
  declare function lex(source: string): string[];
78
77
  //#endregion
79
78
  //#region src/parse/parser.d.ts
80
79
  /**
81
- * A YAML concrete syntax tree (CST) parser
82
- *
83
- * ```ts
84
- * const src: string = ...
85
- * for (const token of new Parser().parse(src)) {
86
- * // token: Token
87
- * }
88
- * ```
89
- *
90
- * To use the parser with a user-provided lexer:
91
- *
92
- * ```ts
93
- * function parse(source: string, lexTokens: string[]) {
94
- * const parser = new Parser()
95
- * for (const lexeme of lexTokens) parser.next(lexeme)
96
- * return parser.end()
97
- * }
98
- *
99
- * const src: string = ...
100
- * for (const token of parse(src, lex(src))) {
101
- * // token: Token
102
- * }
103
- * ```
104
- */
80
+ * A YAML concrete syntax tree (CST) parser
81
+ *
82
+ * ```ts
83
+ * const src: string = ...
84
+ * for (const token of new Parser().parse(src)) {
85
+ * // token: Token
86
+ * }
87
+ * ```
88
+ *
89
+ * To use the parser with a user-provided lexer:
90
+ *
91
+ * ```ts
92
+ * function parse(source: string, lexTokens: string[]) {
93
+ * const parser = new Parser()
94
+ * for (const lexeme of lexTokens) parser.next(lexeme)
95
+ * return parser.end()
96
+ * }
97
+ *
98
+ * const src: string = ...
99
+ * for (const token of parse(src, lex(src))) {
100
+ * // token: Token
101
+ * }
102
+ * ```
103
+ */
105
104
  declare class Parser {
106
105
  private onNewLine?;
107
106
  /** If true, space and sequence indicators count as indentation */
@@ -122,21 +121,21 @@ declare class Parser {
122
121
  private type;
123
122
  tokens: Token[];
124
123
  /**
125
- * @param onNewLine - If defined, called separately with the start position of
126
- * each new line (in `parse()`, including the start of input).
127
- */
124
+ * @param onNewLine - If defined, called separately with the start position of
125
+ * each new line (in `parse()`, including the start of input).
126
+ */
128
127
  constructor(onNewLine?: (offset: number) => void);
129
128
  /**
130
- * Parse `source` as a YAML stream.
131
- *
132
- * Errors are not thrown, but included in the result as `{ type: 'error', message }` tokens.
133
- *
134
- * @returns Tokens representing each directive, document, and other structure.
135
- */
129
+ * Parse `source` as a YAML stream.
130
+ *
131
+ * Errors are not thrown, but included in the result as `{ type: 'error', message }` tokens.
132
+ *
133
+ * @returns Tokens representing each directive, document, and other structure.
134
+ */
136
135
  parse(source: string): Token[];
137
136
  /**
138
- * Advance the parser by the `source` of one lexical token.
139
- */
137
+ * Advance the parser by the `source` of one lexical token.
138
+ */
140
139
  next(source: string): void;
141
140
  /** Call at end of input to account for any remaining constructions */
142
141
  end(): Token[];
@@ -163,38 +162,38 @@ interface EmptyStream extends Array<Document.Parsed>, ReturnType<Composer["strea
163
162
  empty: true;
164
163
  }
165
164
  /**
166
- * Parse the input as a stream of YAML documents.
167
- *
168
- * Documents should be separated from each other by `...` or `---` marker lines.
169
- *
170
- * @returns If an empty `docs` array is returned, it will be of type
171
- * EmptyStream and contain additional stream information. In
172
- * TypeScript, you should use `'empty' in docs` as a type guard for it.
173
- */
165
+ * Parse the input as a stream of YAML documents.
166
+ *
167
+ * Documents should be separated from each other by `...` or `---` marker lines.
168
+ *
169
+ * @returns If an empty `docs` array is returned, it will be of type
170
+ * EmptyStream and contain additional stream information. In
171
+ * TypeScript, you should use `'empty' in docs` as a type guard for it.
172
+ */
174
173
  declare function parseAllDocuments<Value extends DocValue = DocValue, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Document.Parsed<Value, Strict>[] | EmptyStream;
175
174
  /** Parse an input string into a single YAML.Document */
176
175
  declare function parseDocument<Value extends DocValue = DocValue, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Document.Parsed<Value, Strict>;
177
176
  /**
178
- * Parse an input string into JavaScript.
179
- *
180
- * Only supports input consisting of a single YAML document; for multi-document
181
- * support you should use `YAML.parseAllDocuments`. May throw on error, and may
182
- * log warnings using `console.warn`.
183
- *
184
- * @param str - A string with YAML formatting.
185
- * @param reviver - A reviver function, as in `JSON.parse()`
186
- * @returns The value will match the type of the root value of the parsed YAML
187
- * document, so Maps become objects, Sequences arrays, and scalars result in
188
- * nulls, booleans, numbers and strings.
189
- */
177
+ * Parse an input string into JavaScript.
178
+ *
179
+ * Only supports input consisting of a single YAML document; for multi-document
180
+ * support you should use `YAML.parseAllDocuments`. May throw on error, and may
181
+ * log warnings using `console.warn`.
182
+ *
183
+ * @param str - A string with YAML formatting.
184
+ * @param reviver - A reviver function, as in `JSON.parse()`
185
+ * @returns The value will match the type of the root value of the parsed YAML
186
+ * document, so Maps become objects, Sequences arrays, and scalars result in
187
+ * nulls, booleans, numbers and strings.
188
+ */
190
189
  declare function parse(src: string, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
191
190
  declare function parse(src: string, reviver: Reviver, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
192
191
  /**
193
- * Stringify a value as a YAML document.
194
- *
195
- * @param replacer - A replacer array or function, as in `JSON.stringify()`
196
- * @returns Will always include `\n` as the last character, as is expected of YAML documents.
197
- */
192
+ * Stringify a value as a YAML document.
193
+ *
194
+ * @param replacer - A replacer array or function, as in `JSON.stringify()`
195
+ * @returns Will always include `\n` as the last character, as is expected of YAML documents.
196
+ */
198
197
  declare function stringify(value: any, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions): string;
199
198
  declare function stringify(value: any, replacer?: Replacer | null, options?: string | number | (DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions)): string;
200
199
  //#endregion
@@ -202,19 +201,19 @@ declare function stringify(value: any, replacer?: Replacer | null, options?: str
202
201
  declare class YAMLOMap<K extends Primitive | Node = Primitive | Node, V extends Primitive | Node = Primitive | Node> extends YAMLSeq<Pair<K, V>> {
203
202
  constructor(schema: Schema, elements?: Array<Pair<K, V>>);
204
203
  /**
205
- * Append new pairs to the omap, and return its new length.
206
- */
204
+ * Append new pairs to the omap, and return its new length.
205
+ */
207
206
  push(...pairs: Pair<K, V>[]): number;
208
207
  /**
209
- * Set a pair in this omap.
210
- *
211
- * Throws if `idx` is not an integer.
212
- */
208
+ * Set a pair in this omap.
209
+ *
210
+ * Throws if `idx` is not an integer.
211
+ */
213
212
  set(idx: number, pair: Pair<K, V>): void;
214
213
  /**
215
- * The returned value actually has type `Map<unknown, unknown>`,
216
- * but TypeScript won't allow widening the signature of a child method.
217
- */
214
+ * The returned value actually has type `Map<unknown, unknown>`,
215
+ * but TypeScript won't allow widening the signature of a child method.
216
+ */
218
217
  toJS(doc: Document<DocValue, boolean>, ctx?: ToJSContext): never[];
219
218
  toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
220
219
  }
@@ -243,77 +242,83 @@ type asyncVisitor = asyncVisitorFn<Node | Pair | null> | {
243
242
  Value?: asyncVisitorFn<Scalar | YAMLMap | YAMLSeq | YAMLSet>;
244
243
  };
245
244
  /**
246
- * Apply a visitor to an AST node or document.
247
- *
248
- * Walks through the tree (depth-first) starting from `node`, calling a
249
- * `visitor` function with three arguments:
250
- * - `key`: For sequence values and map `Pair`, the node's index in the
251
- * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
252
- * `null` for the root node.
253
- * - `node`: The current node.
254
- * - `path`: The ancestry of the current node.
255
- *
256
- * The return value of the visitor may be used to control the traversal:
257
- * - `undefined` (default): Do nothing and continue
258
- * - `visit.SKIP`: Do not visit the children of this node, continue with next
259
- * sibling
260
- * - `visit.BREAK`: Terminate traversal completely
261
- * - `visit.REMOVE`: Remove the current node, then continue with the next one
262
- * - `Node`: Replace the current node, then continue by visiting it
263
- * - `number`: While iterating the items of a sequence or map, set the index
264
- * of the next step. This is useful especially if the index of the current
265
- * node has changed.
266
- *
267
- * If `visitor` is a single function, it will be called with all values
268
- * encountered in the tree, including e.g. `null` values. Alternatively,
269
- * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
270
- * `Alias` and `Scalar` node. To define the same visitor function for more than
271
- * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
272
- * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
273
- * specific defined one will be used for each node.
274
- */
245
+ * Apply a visitor to an AST node or document.
246
+ *
247
+ * Walks through the tree (depth-first) starting from `node`, calling a
248
+ * `visitor` function with three arguments:
249
+ * - `key`: For sequence values and map `Pair`, the node's index in the
250
+ * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
251
+ * `null` for the root node.
252
+ * - `node`: The current node.
253
+ * - `path`: The ancestry of the current node.
254
+ *
255
+ * The return value of the visitor may be used to control the traversal:
256
+ * - `undefined` (default): Do nothing and continue
257
+ * - `visit.SKIP`: Do not visit the children of this node, continue with next
258
+ * sibling
259
+ * - `visit.BREAK`: Terminate traversal completely
260
+ * - `visit.REMOVE`: Remove the current node, then continue with the next one
261
+ * - `Node`: Replace the current node, then continue by visiting it
262
+ * - `number`: While iterating the items of a sequence or map, set the index
263
+ * of the next step. This is useful especially if the index of the current
264
+ * node has changed.
265
+ *
266
+ * If `visitor` is a single function, it will be called with all values
267
+ * encountered in the tree, including e.g. `null` values. Alternatively,
268
+ * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
269
+ * `Alias` and `Scalar` node. To define the same visitor function for more than
270
+ * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
271
+ * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
272
+ * specific defined one will be used for each node.
273
+ */
275
274
  declare const visit: {
276
- (node: Node | Document | null, visitor: visitor): void; /** Terminate visit traversal completely */
277
- BREAK: symbol; /** Do not visit the children of the current node */
278
- SKIP: symbol; /** Remove the current node */
275
+ (node: Node | Document | null, visitor: visitor): void;
276
+ /** Terminate visit traversal completely */
277
+ BREAK: symbol;
278
+ /** Do not visit the children of the current node */
279
+ SKIP: symbol;
280
+ /** Remove the current node */
279
281
  REMOVE: symbol;
280
282
  };
281
283
  /**
282
- * Apply an async visitor to an AST node or document.
283
- *
284
- * Walks through the tree (depth-first) starting from `node`, calling a
285
- * `visitor` function with three arguments:
286
- * - `key`: For sequence values and map `Pair`, the node's index in the
287
- * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
288
- * `null` for the root node.
289
- * - `node`: The current node.
290
- * - `path`: The ancestry of the current node.
291
- *
292
- * The return value of the visitor may be used to control the traversal:
293
- * - `Promise`: Must resolve to one of the following values
294
- * - `undefined` (default): Do nothing and continue
295
- * - `visitAsync.SKIP`: Do not visit the children of this node,
296
- * continue with next sibling
297
- * - `visitAsync.BREAK`: Terminate traversal completely
298
- * - `visitAsync.REMOVE`: Remove the current node,
299
- * then continue with the next one
300
- * - `Node`: Replace the current node, then continue by visiting it
301
- * - `number`: While iterating the items of a sequence or map, set the index
302
- * of the next step. This is useful especially if the index of the current
303
- * node has changed.
304
- *
305
- * If `visitor` is a single function, it will be called with all values
306
- * encountered in the tree, including e.g. `null` values. Alternatively,
307
- * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
308
- * `Alias` and `Scalar` node. To define the same visitor function for more than
309
- * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
310
- * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
311
- * specific defined one will be used for each node.
312
- */
284
+ * Apply an async visitor to an AST node or document.
285
+ *
286
+ * Walks through the tree (depth-first) starting from `node`, calling a
287
+ * `visitor` function with three arguments:
288
+ * - `key`: For sequence values and map `Pair`, the node's index in the
289
+ * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
290
+ * `null` for the root node.
291
+ * - `node`: The current node.
292
+ * - `path`: The ancestry of the current node.
293
+ *
294
+ * The return value of the visitor may be used to control the traversal:
295
+ * - `Promise`: Must resolve to one of the following values
296
+ * - `undefined` (default): Do nothing and continue
297
+ * - `visitAsync.SKIP`: Do not visit the children of this node,
298
+ * continue with next sibling
299
+ * - `visitAsync.BREAK`: Terminate traversal completely
300
+ * - `visitAsync.REMOVE`: Remove the current node,
301
+ * then continue with the next one
302
+ * - `Node`: Replace the current node, then continue by visiting it
303
+ * - `number`: While iterating the items of a sequence or map, set the index
304
+ * of the next step. This is useful especially if the index of the current
305
+ * node has changed.
306
+ *
307
+ * If `visitor` is a single function, it will be called with all values
308
+ * encountered in the tree, including e.g. `null` values. Alternatively,
309
+ * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
310
+ * `Alias` and `Scalar` node. To define the same visitor function for more than
311
+ * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
312
+ * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
313
+ * specific defined one will be used for each node.
314
+ */
313
315
  declare const visitAsync: {
314
- (node: Node | Document | null, visitor: asyncVisitor): Promise<void>; /** Terminate visit traversal completely */
315
- BREAK: symbol; /** Do not visit the children of the current node */
316
- SKIP: symbol; /** Remove the current node */
316
+ (node: Node | Document | null, visitor: asyncVisitor): Promise<void>;
317
+ /** Terminate visit traversal completely */
318
+ BREAK: symbol;
319
+ /** Do not visit the children of the current node */
320
+ SKIP: symbol;
321
+ /** Remove the current node */
317
322
  REMOVE: symbol;
318
323
  };
319
324
  //#endregion
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as Scalar, a as Schema, d as Pair, f as isCollection, g as YAMLMap, h as YAMLSeq, i as Document, m as YAMLSet, n as visit, p as isNode, r as visitAsync, u as Alias } from "./directives-CiM56lHW.js";
2
- import { a as cst_exports, c as YAMLParseError, i as lex, l as YAMLWarning, n as Composer, r as Parser, s as YAMLError, t as LineCounter } from "./line-counter-bmCJ4fGy.js";
3
- import { i as stringify, n as parseAllDocuments, r as parseDocument, t as parse } from "./public-api-BTMehGT6.js";
1
+ import { S as Scalar, _ as YAMLMap, a as Schema, f as Pair, g as YAMLSeq, h as YAMLSet, i as Document, m as isNode, n as visit, p as isCollection, r as visitAsync, u as Alias } from "./directives-DqP9ea45.js";
2
+ import { a as cst_exports, c as YAMLParseError, i as lex, l as YAMLWarning, n as Composer, r as Parser, s as YAMLError, t as LineCounter } from "./line-counter-B2FjSv3E.js";
3
+ import { i as stringify, n as parseAllDocuments, r as parseDocument, t as parse } from "./public-api-uicovB0N.js";
4
4
  export { Alias, cst_exports as CST, Composer, Document, LineCounter, Pair, Parser, Scalar, Schema, YAMLError, YAMLMap, YAMLParseError, YAMLSeq, YAMLSet, YAMLWarning, isCollection, isNode, lex, parse, parseAllDocuments, parseDocument, stringify, visit, visitAsync };