1 | import { Composer } from './compose/composer.js';
|
---|
2 | import type { Reviver } from './doc/applyReviver.js';
|
---|
3 | import { Document, Replacer } from './doc/Document.js';
|
---|
4 | import type { Node, ParsedNode } from './nodes/Node.js';
|
---|
5 | import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from './options.js';
|
---|
6 | export interface EmptyStream extends Array<Document.Parsed>, ReturnType<Composer['streamInfo']> {
|
---|
7 | empty: true;
|
---|
8 | }
|
---|
9 | /**
|
---|
10 | * Parse the input as a stream of YAML documents.
|
---|
11 | *
|
---|
12 | * Documents should be separated from each other by `...` or `---` marker lines.
|
---|
13 | *
|
---|
14 | * @returns If an empty `docs` array is returned, it will be of type
|
---|
15 | * EmptyStream and contain additional stream information. In
|
---|
16 | * TypeScript, you should use `'empty' in docs` as a type guard for it.
|
---|
17 | */
|
---|
18 | export declare function parseAllDocuments<Contents extends Node = ParsedNode, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Array<Contents extends ParsedNode ? Document.Parsed<Contents, Strict> : Document<Contents, Strict>> | EmptyStream;
|
---|
19 | /** Parse an input string into a single YAML.Document */
|
---|
20 | export declare function parseDocument<Contents extends Node = ParsedNode, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Contents extends ParsedNode ? Document.Parsed<Contents, Strict> : Document<Contents, Strict>;
|
---|
21 | /**
|
---|
22 | * Parse an input string into JavaScript.
|
---|
23 | *
|
---|
24 | * Only supports input consisting of a single YAML document; for multi-document
|
---|
25 | * support you should use `YAML.parseAllDocuments`. May throw on error, and may
|
---|
26 | * log warnings using `console.warn`.
|
---|
27 | *
|
---|
28 | * @param str - A string with YAML formatting.
|
---|
29 | * @param reviver - A reviver function, as in `JSON.parse()`
|
---|
30 | * @returns The value will match the type of the root value of the parsed YAML
|
---|
31 | * document, so Maps become objects, Sequences arrays, and scalars result in
|
---|
32 | * nulls, booleans, numbers and strings.
|
---|
33 | */
|
---|
34 | export declare function parse(src: string, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
|
---|
35 | export declare function parse(src: string, reviver: Reviver, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
|
---|
36 | /**
|
---|
37 | * Stringify a value as a YAML document.
|
---|
38 | *
|
---|
39 | * @param replacer - A replacer array or function, as in `JSON.stringify()`
|
---|
40 | * @returns Will always include `\n` as the last character, as is expected of YAML documents.
|
---|
41 | */
|
---|
42 | export declare function stringify(value: any, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions): string;
|
---|
43 | export declare function stringify(value: any, replacer?: Replacer | null, options?: string | number | (DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions)): string;
|
---|