@depup/js-yaml 5.2.1-depup.9

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.
@@ -0,0 +1,382 @@
1
+ declare const NOT_RESOLVED: unique symbol;
2
+ declare const MERGE_KEY: unique symbol;
3
+ type ScalarRepresent = (data: any) => string;
4
+ type SequenceRepresent = (data: any) => ArrayLike<unknown>;
5
+ type MappingRepresent = (data: any) => Map<unknown, unknown>;
6
+ type IdentifyFn = (data: any) => boolean;
7
+ type RepresentTagNameFn = (data: any) => string;
8
+ interface ScalarTagDefinition<Result = unknown> {
9
+ tagName: string;
10
+ nodeKind: 'scalar';
11
+ implicit: boolean;
12
+ matchByTagPrefix: boolean;
13
+ implicitFirstChars: readonly string[] | null;
14
+ resolve: (source: string, isExplicit: boolean, tagName: string) => Result | typeof NOT_RESOLVED;
15
+ identify: IdentifyFn | null;
16
+ represent: ScalarRepresent;
17
+ representTagName: RepresentTagNameFn | null;
18
+ }
19
+ interface SequenceTagDefinition<Carrier = unknown, Result = Carrier> {
20
+ tagName: string;
21
+ nodeKind: 'sequence';
22
+ implicit: false;
23
+ matchByTagPrefix: boolean;
24
+ create: (tagName: string) => Carrier;
25
+ addItem: (carrier: Carrier, item: unknown, index: number) => void | string;
26
+ finalize: (carrier: Carrier) => Result;
27
+ carrierIsResult: boolean;
28
+ identify: IdentifyFn | null;
29
+ represent: SequenceRepresent;
30
+ representTagName: RepresentTagNameFn | null;
31
+ }
32
+ interface MappingTagDefinition<Carrier = unknown, Result = Carrier> {
33
+ tagName: string;
34
+ nodeKind: 'mapping';
35
+ implicit: false;
36
+ matchByTagPrefix: boolean;
37
+ create: (tagName: string) => Carrier;
38
+ addPair: (carrier: Carrier, key: unknown, value: unknown) => string;
39
+ has: (carrier: Carrier, key: unknown) => boolean;
40
+ keys: (result: Result) => Iterable<unknown>;
41
+ get: (result: Result, key: unknown) => unknown;
42
+ finalize: (carrier: Carrier) => Result;
43
+ carrierIsResult: boolean;
44
+ identify: IdentifyFn | null;
45
+ represent: MappingRepresent;
46
+ representTagName: RepresentTagNameFn | null;
47
+ }
48
+ type TagDefinition = ScalarTagDefinition<any> | SequenceTagDefinition<any, any> | MappingTagDefinition<any, any>;
49
+ interface ScalarTagOptions<Result> {
50
+ implicit?: boolean;
51
+ matchByTagPrefix?: boolean;
52
+ implicitFirstChars?: readonly string[] | null;
53
+ resolve: ScalarTagDefinition<Result>['resolve'];
54
+ identify?: ScalarTagDefinition<Result>['identify'];
55
+ represent?: ScalarTagDefinition<Result>['represent'];
56
+ representTagName?: ScalarTagDefinition<Result>['representTagName'];
57
+ }
58
+ type RepresentOptions<Container, Canonical, Represent> = {
59
+ identify?: null;
60
+ represent?: Represent;
61
+ representTagName?: RepresentTagNameFn | null;
62
+ } | (Container extends Canonical ? {
63
+ identify?: IdentifyFn | null;
64
+ represent?: Represent;
65
+ representTagName?: RepresentTagNameFn | null;
66
+ } : {
67
+ identify: IdentifyFn;
68
+ represent: Represent;
69
+ representTagName?: RepresentTagNameFn | null;
70
+ });
71
+ type SequenceTagOptions<Carrier, Result = Carrier> = {
72
+ matchByTagPrefix?: boolean;
73
+ create: SequenceTagDefinition<Carrier, Result>['create'];
74
+ addItem: SequenceTagDefinition<Carrier, Result>['addItem'];
75
+ finalize?: SequenceTagDefinition<Carrier, Result>['finalize'];
76
+ } & RepresentOptions<Result, ArrayLike<unknown>, SequenceRepresent>;
77
+ type MappingTagOptions<Carrier, Result = Carrier> = {
78
+ matchByTagPrefix?: boolean;
79
+ create: MappingTagDefinition<Carrier, Result>['create'];
80
+ addPair: MappingTagDefinition<Carrier, Result>['addPair'];
81
+ has: MappingTagDefinition<Carrier, Result>['has'];
82
+ keys: MappingTagDefinition<Carrier, Result>['keys'];
83
+ get: MappingTagDefinition<Carrier, Result>['get'];
84
+ finalize?: MappingTagDefinition<Carrier, Result>['finalize'];
85
+ } & RepresentOptions<Result, Map<unknown, unknown>, MappingRepresent>;
86
+ declare function defineScalarTag<Result>(tagName: string, options: ScalarTagOptions<Result>): ScalarTagDefinition<Result>;
87
+ declare function defineSequenceTag<Carrier, Result = Carrier>(tagName: string, options: SequenceTagOptions<Carrier, Result>): SequenceTagDefinition<Carrier, Result>;
88
+ declare function defineMappingTag<Carrier, Result = Carrier>(tagName: string, options: MappingTagOptions<Carrier, Result>): MappingTagDefinition<Carrier, Result>;
89
+
90
+ interface TagDefinitionMap {
91
+ scalar: Record<string, ScalarTagDefinition>;
92
+ sequence: Record<string, SequenceTagDefinition>;
93
+ mapping: Record<string, MappingTagDefinition>;
94
+ }
95
+ interface TagDefinitionListMap {
96
+ scalar: ScalarTagDefinition[];
97
+ sequence: SequenceTagDefinition[];
98
+ mapping: MappingTagDefinition[];
99
+ }
100
+ declare class Schema {
101
+ readonly tags: readonly TagDefinition[];
102
+ readonly implicitScalarTags: readonly ScalarTagDefinition[];
103
+ readonly implicitScalarByFirstChar: ReadonlyMap<string, readonly ScalarTagDefinition[]>;
104
+ readonly implicitScalarAnyFirstChar: readonly ScalarTagDefinition[];
105
+ readonly defaultScalarTag: ScalarTagDefinition;
106
+ readonly defaultSequenceTag: SequenceTagDefinition | undefined;
107
+ readonly defaultMappingTag: MappingTagDefinition | undefined;
108
+ readonly exact: TagDefinitionMap;
109
+ readonly prefix: TagDefinitionListMap;
110
+ constructor(tags: readonly TagDefinition[]);
111
+ withTags(...tags: Array<TagDefinition | readonly TagDefinition[]>): Schema;
112
+ }
113
+ declare const FAILSAFE_SCHEMA: Schema;
114
+ declare const JSON_SCHEMA: Schema;
115
+ declare const CORE_SCHEMA: Schema;
116
+ declare const YAML11_SCHEMA: Schema;
117
+
118
+ declare const strTag: ScalarTagDefinition<string>;
119
+
120
+ declare const nullCoreTag: ScalarTagDefinition<null>;
121
+
122
+ declare const nullJsonTag: ScalarTagDefinition<null>;
123
+
124
+ declare const nullYaml11Tag: ScalarTagDefinition<null>;
125
+
126
+ declare const boolCoreTag: ScalarTagDefinition<boolean>;
127
+
128
+ declare const boolJsonTag: ScalarTagDefinition<boolean>;
129
+
130
+ declare const boolYaml11Tag: ScalarTagDefinition<boolean>;
131
+
132
+ declare const intCoreTag: ScalarTagDefinition<number>;
133
+
134
+ declare const intJsonTag: ScalarTagDefinition<number>;
135
+
136
+ declare const intYaml11Tag: ScalarTagDefinition<number>;
137
+
138
+ declare const floatCoreTag: ScalarTagDefinition<number>;
139
+
140
+ declare const floatJsonTag: ScalarTagDefinition<number>;
141
+
142
+ declare const floatYaml11Tag: ScalarTagDefinition<number>;
143
+
144
+ declare const mergeTag: ScalarTagDefinition<typeof MERGE_KEY>;
145
+
146
+ declare const binaryTag: ScalarTagDefinition<Uint8Array<ArrayBuffer>>;
147
+
148
+ declare const timestampTag: ScalarTagDefinition<Date>;
149
+
150
+ declare const seqTag: SequenceTagDefinition<unknown[], unknown[]>;
151
+
152
+ interface OmapCarrier {
153
+ list: unknown[];
154
+ seen: Set<unknown>;
155
+ }
156
+ declare const omapTag: SequenceTagDefinition<OmapCarrier, unknown[]>;
157
+
158
+ type Pair = [unknown, unknown];
159
+ declare const pairsTag: SequenceTagDefinition<Pair[], Pair[]>;
160
+
161
+ type StringMapping$1 = Record<string, unknown>;
162
+ declare const mapTag: MappingTagDefinition<StringMapping$1, StringMapping$1>;
163
+
164
+ type RealMapping = Map<unknown, unknown>;
165
+ declare const realMapTag: MappingTagDefinition<RealMapping, RealMapping>;
166
+
167
+ type StringMapping = Record<string, unknown>;
168
+ declare const legacyMapTag: MappingTagDefinition<StringMapping, StringMapping>;
169
+
170
+ declare const setTag: MappingTagDefinition<Set<unknown>, Set<unknown>>;
171
+
172
+ declare const EVENT_DOCUMENT = 1;
173
+ declare const EVENT_SEQUENCE = 2;
174
+ declare const EVENT_MAPPING = 3;
175
+ declare const EVENT_SCALAR = 4;
176
+ declare const EVENT_ALIAS = 5;
177
+ declare const EVENT_POP = 6;
178
+ declare const SCALAR_STYLE_PLAIN = 1;
179
+ declare const SCALAR_STYLE_SINGLE_QUOTED = 2;
180
+ declare const SCALAR_STYLE_DOUBLE_QUOTED = 3;
181
+ declare const SCALAR_STYLE_LITERAL_BLOCK = 4;
182
+ declare const SCALAR_STYLE_FOLDED_BLOCK = 5;
183
+ type ScalarStyle = typeof SCALAR_STYLE_PLAIN | typeof SCALAR_STYLE_SINGLE_QUOTED | typeof SCALAR_STYLE_DOUBLE_QUOTED | typeof SCALAR_STYLE_LITERAL_BLOCK | typeof SCALAR_STYLE_FOLDED_BLOCK;
184
+ declare const COLLECTION_STYLE_BLOCK = 1;
185
+ declare const COLLECTION_STYLE_FLOW = 2;
186
+ type CollectionStyle = typeof COLLECTION_STYLE_BLOCK | typeof COLLECTION_STYLE_FLOW;
187
+ declare const CHOMPING_CLIP = 1;
188
+ declare const CHOMPING_STRIP = 2;
189
+ declare const CHOMPING_KEEP = 3;
190
+ type Chomping = typeof CHOMPING_CLIP | typeof CHOMPING_STRIP | typeof CHOMPING_KEEP;
191
+ type DocumentDirective = {
192
+ kind: 'yaml';
193
+ version: string;
194
+ } | {
195
+ kind: 'tag';
196
+ handle: string;
197
+ prefix: string;
198
+ };
199
+ interface DocumentEvent {
200
+ type: typeof EVENT_DOCUMENT;
201
+ explicitStart: boolean;
202
+ explicitEnd: boolean;
203
+ directives: DocumentDirective[];
204
+ }
205
+ interface SequenceEvent {
206
+ type: typeof EVENT_SEQUENCE;
207
+ start: number;
208
+ anchorStart: number;
209
+ anchorEnd: number;
210
+ tagStart: number;
211
+ tagEnd: number;
212
+ style: CollectionStyle;
213
+ }
214
+ interface MappingEvent {
215
+ type: typeof EVENT_MAPPING;
216
+ start: number;
217
+ anchorStart: number;
218
+ anchorEnd: number;
219
+ tagStart: number;
220
+ tagEnd: number;
221
+ style: CollectionStyle;
222
+ }
223
+ interface ScalarEvent {
224
+ type: typeof EVENT_SCALAR;
225
+ valueStart: number;
226
+ valueEnd: number;
227
+ anchorStart: number;
228
+ anchorEnd: number;
229
+ tagStart: number;
230
+ tagEnd: number;
231
+ style: ScalarStyle;
232
+ chomping: Chomping;
233
+ indent: number;
234
+ fast: boolean;
235
+ }
236
+ interface AliasEvent {
237
+ type: typeof EVENT_ALIAS;
238
+ anchorStart: number;
239
+ anchorEnd: number;
240
+ }
241
+ interface PopEvent {
242
+ type: typeof EVENT_POP;
243
+ }
244
+ type Event = DocumentEvent | SequenceEvent | MappingEvent | ScalarEvent | AliasEvent | PopEvent;
245
+
246
+ interface ConstructorOptions {
247
+ source: string;
248
+ filename?: string;
249
+ schema?: Schema;
250
+ json?: boolean;
251
+ maxTotalMergeKeys?: number;
252
+ maxAliases?: number;
253
+ }
254
+ declare function constructFromEvents(events: Event[], options: ConstructorOptions): unknown[];
255
+
256
+ interface ParserOptions {
257
+ filename?: string;
258
+ maxDepth?: number;
259
+ }
260
+ declare function parseEvents(input: string, options: ParserOptions): Event[];
261
+
262
+ interface LoadOptions extends ParserOptions, Omit<ConstructorOptions, 'source'> {
263
+ }
264
+ type LoadAllIterator = (document: unknown) => void;
265
+ declare function loadAll(input: string, options?: LoadOptions): unknown[];
266
+ declare function loadAll(input: string, iterator: null, options?: LoadOptions): unknown[];
267
+ declare function loadAll(input: string, iterator: LoadAllIterator, options?: LoadOptions): void;
268
+ declare function load(input: string, options?: LoadOptions): unknown;
269
+
270
+ declare class Style {
271
+ tagged: boolean;
272
+ flow: boolean;
273
+ singleQuoted: boolean;
274
+ doubleQuoted: boolean;
275
+ literal: boolean;
276
+ folded: boolean;
277
+ }
278
+ interface NodeBase {
279
+ tag: string;
280
+ style: Style;
281
+ anchor?: string;
282
+ commentBefore?: string;
283
+ comment?: string;
284
+ commentAfter?: string;
285
+ blankBefore?: number;
286
+ }
287
+ interface ScalarNode extends NodeBase {
288
+ kind: 'scalar';
289
+ value: string;
290
+ }
291
+ interface SequenceNode extends NodeBase {
292
+ kind: 'sequence';
293
+ items: Node[];
294
+ }
295
+ interface MappingNode extends NodeBase {
296
+ kind: 'mapping';
297
+ items: Array<{
298
+ key: Node;
299
+ value: Node;
300
+ }>;
301
+ }
302
+ interface AliasNode extends NodeBase {
303
+ kind: 'alias';
304
+ anchor: string;
305
+ }
306
+ type Node = ScalarNode | SequenceNode | MappingNode | AliasNode;
307
+ interface Document {
308
+ contents: Node | null;
309
+ explicitStart?: boolean;
310
+ explicitEnd?: boolean;
311
+ directives: DocumentDirective[];
312
+ }
313
+
314
+ interface PresenterOptions {
315
+ schema: Schema;
316
+ indent?: number;
317
+ seqNoIndent?: boolean;
318
+ seqInlineFirst?: boolean;
319
+ sortKeys?: boolean | ((a: any, b: any) => number);
320
+ lineWidth?: number;
321
+ flowBracketPadding?: boolean;
322
+ flowSkipCommaSpace?: boolean;
323
+ flowSkipColonSpace?: boolean;
324
+ quoteFlowKeys?: boolean;
325
+ quoteStyle?: 'single' | 'double';
326
+ forceQuotes?: boolean;
327
+ tagBeforeAnchor?: boolean;
328
+ }
329
+ declare function present(documents: Document[], options: PresenterOptions): string;
330
+
331
+ interface DumpOptions extends Omit<PresenterOptions, 'schema'> {
332
+ schema?: Schema;
333
+ skipInvalid?: boolean;
334
+ noRefs?: boolean;
335
+ flowLevel?: number;
336
+ transform?: (documents: Document[]) => void;
337
+ }
338
+ declare function dump(input: any, options?: DumpOptions): string;
339
+
340
+ interface SnippetMark {
341
+ name?: string | null;
342
+ buffer: string;
343
+ position: number;
344
+ line: number;
345
+ column: number;
346
+ snippet?: string | null;
347
+ }
348
+
349
+ declare class YAMLException extends Error {
350
+ reason: string;
351
+ mark?: SnippetMark;
352
+ constructor(reason: string, mark?: SnippetMark);
353
+ toString(compact?: boolean): string;
354
+ }
355
+
356
+ declare function getScalarValue(input: string, scalar: ScalarEvent): string;
357
+
358
+ interface FromEventsOptions {
359
+ source: string;
360
+ schema: Schema;
361
+ }
362
+ declare function eventsToAst(events: Event[], options: FromEventsOptions): Document[];
363
+
364
+ interface FromJsOptions {
365
+ noRefs?: boolean;
366
+ skipInvalid?: boolean;
367
+ }
368
+ declare function jsToAst(input: unknown, schema: Schema, options?: FromJsOptions): Document[];
369
+
370
+ declare const VISIT_BREAK: unique symbol;
371
+ declare const VISIT_SKIP: unique symbol;
372
+ type VisitControl = typeof VISIT_BREAK | typeof VISIT_SKIP | undefined | void;
373
+ interface VisitContext {
374
+ depth: number;
375
+ parent: Node | null;
376
+ isKey: boolean;
377
+ }
378
+ type Visitor = (node: Node, ctx: VisitContext) => VisitControl;
379
+ declare function visit(documents: Document[], visitor: Visitor): void;
380
+
381
+ export { CHOMPING_CLIP, CHOMPING_KEEP, CHOMPING_STRIP, COLLECTION_STYLE_BLOCK, COLLECTION_STYLE_FLOW, CORE_SCHEMA, EVENT_ALIAS, EVENT_DOCUMENT, EVENT_MAPPING, EVENT_POP, EVENT_SCALAR, EVENT_SEQUENCE, FAILSAFE_SCHEMA, JSON_SCHEMA, MERGE_KEY, NOT_RESOLVED, SCALAR_STYLE_DOUBLE_QUOTED, SCALAR_STYLE_FOLDED_BLOCK, SCALAR_STYLE_LITERAL_BLOCK, SCALAR_STYLE_PLAIN, SCALAR_STYLE_SINGLE_QUOTED, Schema, Style, VISIT_BREAK, VISIT_SKIP, YAML11_SCHEMA, YAMLException, binaryTag, boolCoreTag, boolJsonTag, boolYaml11Tag, constructFromEvents, defineMappingTag, defineScalarTag, defineSequenceTag, dump, eventsToAst, floatCoreTag, floatJsonTag, floatYaml11Tag, getScalarValue, intCoreTag, intJsonTag, intYaml11Tag, jsToAst, legacyMapTag, load, loadAll, mapTag, mergeTag, nullCoreTag, nullJsonTag, nullYaml11Tag, omapTag, pairsTag, parseEvents, present, realMapTag, seqTag, setTag, strTag, timestampTag, visit };
382
+ export type { AliasEvent, AliasNode, ConstructorOptions, Document, DocumentDirective, DocumentEvent, DumpOptions, Event, FromEventsOptions, FromJsOptions, LoadOptions, MappingEvent, MappingNode, MappingTagDefinition, MappingTagOptions, Node, NodeBase, ParserOptions, PopEvent, PresenterOptions, ScalarEvent, ScalarNode, ScalarTagDefinition, ScalarTagOptions, SequenceEvent, SequenceNode, SequenceTagDefinition, SequenceTagOptions, TagDefinition, VisitContext, Visitor };