yaml 3.0.0-0 → 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/cli.js +4 -5
- package/dist/directives-CGITitH5.d.ts +1377 -0
- package/dist/{directives-CG6n4xSM.js → directives-DqP9ea45.js} +1252 -1010
- package/dist/index.d.ts +201 -211
- package/dist/index.js +4 -5
- package/dist/{line-counter-TFl552k_.js → line-counter-B2FjSv3E.js} +346 -296
- package/dist/{public-api-BE74JyVm.js → public-api-uicovB0N.js} +7 -7
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/test-events.js +17 -12
- package/dist/util.d.ts +2 -2
- package/dist/util.js +2 -3
- package/package.json +6 -6
- package/dist/chunk-BYypO7fO.js +0 -18
- package/dist/stringifyString-S_ITVLTO.d.ts +0 -1306
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { A as
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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,66 +35,72 @@ declare class Composer<Value extends DocValue = DocValue, Strict extends boolean
|
|
|
36
35
|
warnings: YAMLWarning[];
|
|
37
36
|
};
|
|
38
37
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
55
|
+
//#region src/nodes/identity.d.ts
|
|
56
|
+
/** Type predicate for collections */
|
|
57
|
+
declare const isCollection: (node: unknown) => node is YAMLMap | YAMLSeq | YAMLSet;
|
|
58
|
+
/** Type predicate for `Node` values */
|
|
59
|
+
declare const isNode: (node: unknown) => node is Node;
|
|
60
|
+
//#endregion
|
|
56
61
|
//#region src/parse/lexer.d.ts
|
|
57
62
|
/**
|
|
58
|
-
* Splits an input `source` string into lexical YAML tokens,
|
|
59
|
-
* i.e. smaller strings that are easily identifiable by `tokens.tokenType()`.
|
|
60
|
-
*
|
|
61
|
-
* Lexing starts always in a "stream" context.
|
|
62
|
-
*
|
|
63
|
-
* In addition to slices of the original input, the following control characters
|
|
64
|
-
* may also be emitted:
|
|
65
|
-
*
|
|
66
|
-
* - `\x02` (Start of Text): A document starts with the next token
|
|
67
|
-
* - `\x18` (Cancel): Unexpected end of flow-mode (indicates an error)
|
|
68
|
-
* - `\x1f` (Unit Separator): Next token is a scalar value
|
|
69
|
-
* - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
|
|
70
|
-
*/
|
|
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
|
+
*/
|
|
71
76
|
declare function lex(source: string): string[];
|
|
72
77
|
//#endregion
|
|
73
78
|
//#region src/parse/parser.d.ts
|
|
74
79
|
/**
|
|
75
|
-
* A YAML concrete syntax tree (CST) parser
|
|
76
|
-
*
|
|
77
|
-
* ```ts
|
|
78
|
-
* const src: string = ...
|
|
79
|
-
* for (const token of new Parser().parse(src)) {
|
|
80
|
-
* // token: Token
|
|
81
|
-
* }
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* To use the parser with a user-provided lexer:
|
|
85
|
-
*
|
|
86
|
-
* ```ts
|
|
87
|
-
* function parse(source: string, lexTokens: string[]) {
|
|
88
|
-
* const parser = new Parser()
|
|
89
|
-
* for (const lexeme of lexTokens) parser.next(lexeme)
|
|
90
|
-
* return parser.end()
|
|
91
|
-
* }
|
|
92
|
-
*
|
|
93
|
-
* const src: string = ...
|
|
94
|
-
* for (const token of parse(src, lex(src))) {
|
|
95
|
-
* // token: Token
|
|
96
|
-
* }
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
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
|
+
*/
|
|
99
104
|
declare class Parser {
|
|
100
105
|
private onNewLine?;
|
|
101
106
|
/** If true, space and sequence indicators count as indentation */
|
|
@@ -116,21 +121,21 @@ declare class Parser {
|
|
|
116
121
|
private type;
|
|
117
122
|
tokens: Token[];
|
|
118
123
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
* @param onNewLine - If defined, called separately with the start position of
|
|
125
|
+
* each new line (in `parse()`, including the start of input).
|
|
126
|
+
*/
|
|
122
127
|
constructor(onNewLine?: (offset: number) => void);
|
|
123
128
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
*/
|
|
130
135
|
parse(source: string): Token[];
|
|
131
136
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
* Advance the parser by the `source` of one lexical token.
|
|
138
|
+
*/
|
|
134
139
|
next(source: string): void;
|
|
135
140
|
/** Call at end of input to account for any remaining constructions */
|
|
136
141
|
end(): Token[];
|
|
@@ -157,179 +162,164 @@ interface EmptyStream extends Array<Document.Parsed>, ReturnType<Composer["strea
|
|
|
157
162
|
empty: true;
|
|
158
163
|
}
|
|
159
164
|
/**
|
|
160
|
-
* Parse the input as a stream of YAML documents.
|
|
161
|
-
*
|
|
162
|
-
* Documents should be separated from each other by `...` or `---` marker lines.
|
|
163
|
-
*
|
|
164
|
-
* @returns If an empty `docs` array is returned, it will be of type
|
|
165
|
-
* EmptyStream and contain additional stream information. In
|
|
166
|
-
* TypeScript, you should use `'empty' in docs` as a type guard for it.
|
|
167
|
-
*/
|
|
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
|
+
*/
|
|
168
173
|
declare function parseAllDocuments<Value extends DocValue = DocValue, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Document.Parsed<Value, Strict>[] | EmptyStream;
|
|
169
174
|
/** Parse an input string into a single YAML.Document */
|
|
170
175
|
declare function parseDocument<Value extends DocValue = DocValue, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Document.Parsed<Value, Strict>;
|
|
171
176
|
/**
|
|
172
|
-
* Parse an input string into JavaScript.
|
|
173
|
-
*
|
|
174
|
-
* Only supports input consisting of a single YAML document; for multi-document
|
|
175
|
-
* support you should use `YAML.parseAllDocuments`. May throw on error, and may
|
|
176
|
-
* log warnings using `console.warn`.
|
|
177
|
-
*
|
|
178
|
-
* @param str - A string with YAML formatting.
|
|
179
|
-
* @param reviver - A reviver function, as in `JSON.parse()`
|
|
180
|
-
* @returns The value will match the type of the root value of the parsed YAML
|
|
181
|
-
* document, so Maps become objects, Sequences arrays, and scalars result in
|
|
182
|
-
* nulls, booleans, numbers and strings.
|
|
183
|
-
*/
|
|
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
|
+
*/
|
|
184
189
|
declare function parse(src: string, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
|
|
185
190
|
declare function parse(src: string, reviver: Reviver, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
|
|
186
191
|
/**
|
|
187
|
-
* Stringify a value as a YAML document.
|
|
188
|
-
*
|
|
189
|
-
* @param replacer - A replacer array or function, as in `JSON.stringify()`
|
|
190
|
-
* @returns Will always include `\n` as the last character, as is expected of YAML documents.
|
|
191
|
-
*/
|
|
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
|
+
*/
|
|
192
197
|
declare function stringify(value: any, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions): string;
|
|
193
198
|
declare function stringify(value: any, replacer?: Replacer | null, options?: string | number | (DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions)): string;
|
|
194
199
|
//#endregion
|
|
195
200
|
//#region src/schema/yaml-1.1/omap.d.ts
|
|
196
|
-
declare class YAMLOMap<K extends Primitive |
|
|
197
|
-
|
|
198
|
-
constructor(schema?: Schema);
|
|
199
|
-
add: typeof YAMLMap.prototype.add;
|
|
200
|
-
delete: typeof YAMLMap.prototype.delete;
|
|
201
|
-
get: typeof YAMLMap.prototype.get;
|
|
202
|
-
has: typeof YAMLMap.prototype.has;
|
|
203
|
-
set: typeof YAMLMap.prototype.set;
|
|
204
|
-
/**
|
|
205
|
-
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
206
|
-
* but TypeScript won't allow widening the signature of a child method.
|
|
207
|
-
*/
|
|
208
|
-
toJSON(_?: unknown, ctx?: ToJSContext): unknown[];
|
|
209
|
-
static from(nc: NodeCreator, iterable: unknown): YAMLOMap;
|
|
210
|
-
}
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region src/schema/yaml-1.1/set.d.ts
|
|
213
|
-
declare class YAMLSet<T extends Primitive | NodeBase = Primitive | NodeBase> extends YAMLMap<T, T> {
|
|
214
|
-
static tag: string;
|
|
215
|
-
constructor(schema?: Schema);
|
|
201
|
+
declare class YAMLOMap<K extends Primitive | Node = Primitive | Node, V extends Primitive | Node = Primitive | Node> extends YAMLSeq<Pair<K, V>> {
|
|
202
|
+
constructor(schema: Schema, elements?: Array<Pair<K, V>>);
|
|
216
203
|
/**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
*
|
|
221
|
-
* If the set already includes a matching value, no value is added.
|
|
222
|
-
*/
|
|
223
|
-
add(value: unknown, options?: Omit<CreateNodeOptions, "aliasDuplicateObjects">): void;
|
|
204
|
+
* Append new pairs to the omap, and return its new length.
|
|
205
|
+
*/
|
|
206
|
+
push(...pairs: Pair<K, V>[]): number;
|
|
224
207
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
208
|
+
* Set a pair in this omap.
|
|
209
|
+
*
|
|
210
|
+
* Throws if `idx` is not an integer.
|
|
211
|
+
*/
|
|
212
|
+
set(idx: number, pair: Pair<K, V>): void;
|
|
228
213
|
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
214
|
+
* The returned value actually has type `Map<unknown, unknown>`,
|
|
215
|
+
* but TypeScript won't allow widening the signature of a child method.
|
|
216
|
+
*/
|
|
217
|
+
toJS(doc: Document<DocValue, boolean>, ctx?: ToJSContext): never[];
|
|
233
218
|
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
|
234
|
-
static from(nc: NodeCreator, iterable: unknown): YAMLSet;
|
|
235
219
|
}
|
|
236
220
|
//#endregion
|
|
237
221
|
//#region src/visit.d.ts
|
|
238
222
|
type visitorFn<T> = (key: number | "key" | "value" | null, node: T, path: readonly (Document | Node | Pair)[]) => void | symbol | number | Node | Pair;
|
|
239
|
-
type visitor = visitorFn<
|
|
223
|
+
type visitor = visitorFn<Node | Pair | null> | {
|
|
240
224
|
Alias?: visitorFn<Alias>;
|
|
241
|
-
Collection?: visitorFn<YAMLMap | YAMLSeq>;
|
|
242
|
-
Map?: visitorFn<YAMLMap>;
|
|
243
|
-
Node?: visitorFn<Alias | Scalar | YAMLMap | YAMLSeq>;
|
|
225
|
+
Collection?: visitorFn<YAMLMap | YAMLSeq | YAMLSet>;
|
|
226
|
+
Map?: visitorFn<YAMLMap | YAMLSet>;
|
|
227
|
+
Node?: visitorFn<Alias | Scalar | YAMLMap | YAMLSeq | YAMLSet>;
|
|
244
228
|
Pair?: visitorFn<Pair>;
|
|
245
229
|
Scalar?: visitorFn<Scalar>;
|
|
246
230
|
Seq?: visitorFn<YAMLSeq>;
|
|
247
|
-
Value?: visitorFn<Scalar | YAMLMap | YAMLSeq>;
|
|
231
|
+
Value?: visitorFn<Scalar | YAMLMap | YAMLSeq | YAMLSet>;
|
|
248
232
|
};
|
|
249
233
|
type asyncVisitorFn<T> = (key: number | "key" | "value" | null, node: T, path: readonly (Document | Node | Pair)[]) => void | symbol | number | Node | Pair | Promise<void | symbol | number | Node | Pair>;
|
|
250
|
-
type asyncVisitor = asyncVisitorFn<
|
|
234
|
+
type asyncVisitor = asyncVisitorFn<Node | Pair | null> | {
|
|
251
235
|
Alias?: asyncVisitorFn<Alias>;
|
|
252
|
-
Collection?: asyncVisitorFn<YAMLMap | YAMLSeq>;
|
|
253
|
-
Map?: asyncVisitorFn<YAMLMap>;
|
|
254
|
-
Node?: asyncVisitorFn<Alias | Scalar | YAMLMap | YAMLSeq>;
|
|
236
|
+
Collection?: asyncVisitorFn<YAMLMap | YAMLSeq | YAMLSet>;
|
|
237
|
+
Map?: asyncVisitorFn<YAMLMap | YAMLSet>;
|
|
238
|
+
Node?: asyncVisitorFn<Alias | Scalar | YAMLMap | YAMLSeq | YAMLSet>;
|
|
255
239
|
Pair?: asyncVisitorFn<Pair>;
|
|
256
240
|
Scalar?: asyncVisitorFn<Scalar>;
|
|
257
241
|
Seq?: asyncVisitorFn<YAMLSeq>;
|
|
258
|
-
Value?: asyncVisitorFn<Scalar | YAMLMap | YAMLSeq>;
|
|
242
|
+
Value?: asyncVisitorFn<Scalar | YAMLMap | YAMLSeq | YAMLSet>;
|
|
259
243
|
};
|
|
260
244
|
/**
|
|
261
|
-
* Apply a visitor to an AST node or document.
|
|
262
|
-
*
|
|
263
|
-
* Walks through the tree (depth-first) starting from `node`, calling a
|
|
264
|
-
* `visitor` function with three arguments:
|
|
265
|
-
* - `key`: For sequence values and map `Pair`, the node's index in the
|
|
266
|
-
* collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
|
|
267
|
-
* `null` for the root node.
|
|
268
|
-
* - `node`: The current node.
|
|
269
|
-
* - `path`: The ancestry of the current node.
|
|
270
|
-
*
|
|
271
|
-
* The return value of the visitor may be used to control the traversal:
|
|
272
|
-
* - `undefined` (default): Do nothing and continue
|
|
273
|
-
* - `visit.SKIP`: Do not visit the children of this node, continue with next
|
|
274
|
-
* sibling
|
|
275
|
-
* - `visit.BREAK`: Terminate traversal completely
|
|
276
|
-
* - `visit.REMOVE`: Remove the current node, then continue with the next one
|
|
277
|
-
* - `Node`: Replace the current node, then continue by visiting it
|
|
278
|
-
* - `number`: While iterating the items of a sequence or map, set the index
|
|
279
|
-
* of the next step. This is useful especially if the index of the current
|
|
280
|
-
* node has changed.
|
|
281
|
-
*
|
|
282
|
-
* If `visitor` is a single function, it will be called with all values
|
|
283
|
-
* encountered in the tree, including e.g. `null` values. Alternatively,
|
|
284
|
-
* separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
|
|
285
|
-
* `Alias` and `Scalar` node. To define the same visitor function for more than
|
|
286
|
-
* one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
|
|
287
|
-
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
288
|
-
* specific defined one will be used for each node.
|
|
289
|
-
*/
|
|
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
|
+
*/
|
|
290
274
|
declare const visit: {
|
|
291
|
-
(node: Node | Document | null, visitor: visitor): void;
|
|
292
|
-
|
|
293
|
-
|
|
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 */
|
|
294
281
|
REMOVE: symbol;
|
|
295
282
|
};
|
|
296
283
|
/**
|
|
297
|
-
* Apply an async visitor to an AST node or document.
|
|
298
|
-
*
|
|
299
|
-
* Walks through the tree (depth-first) starting from `node`, calling a
|
|
300
|
-
* `visitor` function with three arguments:
|
|
301
|
-
* - `key`: For sequence values and map `Pair`, the node's index in the
|
|
302
|
-
* collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
|
|
303
|
-
* `null` for the root node.
|
|
304
|
-
* - `node`: The current node.
|
|
305
|
-
* - `path`: The ancestry of the current node.
|
|
306
|
-
*
|
|
307
|
-
* The return value of the visitor may be used to control the traversal:
|
|
308
|
-
* - `Promise`: Must resolve to one of the following values
|
|
309
|
-
* - `undefined` (default): Do nothing and continue
|
|
310
|
-
* - `visitAsync.SKIP`: Do not visit the children of this node,
|
|
311
|
-
* continue with next sibling
|
|
312
|
-
* - `visitAsync.BREAK`: Terminate traversal completely
|
|
313
|
-
* - `visitAsync.REMOVE`: Remove the current node,
|
|
314
|
-
* then continue with the next one
|
|
315
|
-
* - `Node`: Replace the current node, then continue by visiting it
|
|
316
|
-
* - `number`: While iterating the items of a sequence or map, set the index
|
|
317
|
-
* of the next step. This is useful especially if the index of the current
|
|
318
|
-
* node has changed.
|
|
319
|
-
*
|
|
320
|
-
* If `visitor` is a single function, it will be called with all values
|
|
321
|
-
* encountered in the tree, including e.g. `null` values. Alternatively,
|
|
322
|
-
* separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
|
|
323
|
-
* `Alias` and `Scalar` node. To define the same visitor function for more than
|
|
324
|
-
* one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
|
|
325
|
-
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
326
|
-
* specific defined one will be used for each node.
|
|
327
|
-
*/
|
|
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
|
+
*/
|
|
328
315
|
declare const visitAsync: {
|
|
329
|
-
(node: Node | Document | null, visitor: asyncVisitor): Promise<void>;
|
|
330
|
-
|
|
331
|
-
|
|
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 */
|
|
332
322
|
REMOVE: symbol;
|
|
333
323
|
};
|
|
334
324
|
//#endregion
|
|
335
|
-
export { Alias, cst_d_exports as CST, type CollectionTag, Composer, type CreateNodeOptions, type DocValue, Document, type DocumentOptions, type EmptyStream, type ErrorCode, LineCounter, type Node, Pair, type ParseOptions, Parser, type Range, Scalar, type ScalarTag, Schema, type SchemaOptions, type TagId, type Tags, type ToJSOptions, type ToStringOptions, YAMLError, YAMLMap, type YAMLOMap, YAMLParseError, YAMLSeq,
|
|
325
|
+
export { Alias, cst_d_exports as CST, type CollectionTag, Composer, type CreateNodeOptions, type DocValue, Document, type DocumentOptions, type EmptyStream, type ErrorCode, type KeyArg, LineCounter, type Node, type NodeBase, Pair, type ParseOptions, Parser, type Range, Scalar, type ScalarTag, Schema, type SchemaOptions, type TagId, type Tags, type ToJSOptions, type ToStringOptions, YAMLError, YAMLMap, type YAMLOMap, YAMLParseError, YAMLSeq, YAMLSet, YAMLWarning, type asyncVisitor, type asyncVisitorFn, isCollection, isNode, lex, parse, parseAllDocuments, parseDocument, stringify, visit, visitAsync, type visitor, type visitorFn };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
3
|
-
import { i as stringify, n as parseAllDocuments, r as parseDocument, t as parse } from "./public-api-
|
|
4
|
-
|
|
5
|
-
export { Alias, cst_exports as CST, Composer, Document, LineCounter, Pair, Parser, Scalar, Schema, YAMLError, YAMLMap, YAMLParseError, YAMLSeq, YAMLWarning, lex, parse, parseAllDocuments, parseDocument, stringify, visit, visitAsync };
|
|
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
|
+
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 };
|