1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export as namespace jsyaml;
|
12 |
|
13 | export function load(str: string, opts?: LoadOptions): unknown;
|
14 |
|
15 | export class Type {
|
16 | constructor(tag: string, opts?: TypeConstructorOptions);
|
17 | kind: 'sequence' | 'scalar' | 'mapping' | null;
|
18 | resolve(data: any): boolean;
|
19 | construct(data: any, type?: string): any;
|
20 | instanceOf: object | null;
|
21 | predicate: ((data: object) => boolean) | null;
|
22 | represent: ((data: object) => any) | { [x: string]: (data: object) => any } | null;
|
23 | representName: ((data: object) => any) | null;
|
24 | defaultStyle: string | null;
|
25 | multi: boolean;
|
26 | styleAliases: { [x: string]: any };
|
27 | }
|
28 |
|
29 | export class Schema {
|
30 | constructor(definition: SchemaDefinition | Type[] | Type);
|
31 | extend(types: SchemaDefinition | Type[] | Type): Schema;
|
32 | }
|
33 |
|
34 | export function loadAll(str: string, iterator?: null, opts?: LoadOptions): unknown[];
|
35 | export function loadAll(str: string, iterator: (doc: unknown) => void, opts?: LoadOptions): void;
|
36 |
|
37 | export function dump(obj: any, opts?: DumpOptions): string;
|
38 |
|
39 | export interface LoadOptions {
|
40 | /** string to be used as a file path in error/warning messages. */
|
41 | filename?: string | undefined;
|
42 | /** function to call on warning messages. */
|
43 | onWarning?(this: null, e: YAMLException): void;
|
44 | /** specifies a schema to use. */
|
45 | schema?: Schema | undefined;
|
46 | /** compatibility with JSON.parse behaviour. */
|
47 | json?: boolean | undefined;
|
48 | /** listener for parse events */
|
49 | listener?(this: State, eventType: EventType, state: State): void;
|
50 | }
|
51 |
|
52 | export type EventType = 'open' | 'close';
|
53 |
|
54 | export interface State {
|
55 | input: string;
|
56 | filename: string | null;
|
57 | schema: Schema;
|
58 | onWarning: (this: null, e: YAMLException) => void;
|
59 | json: boolean;
|
60 | length: number;
|
61 | position: number;
|
62 | line: number;
|
63 | lineStart: number;
|
64 | lineIndent: number;
|
65 | version: null | number;
|
66 | checkLineBreaks: boolean;
|
67 | kind: string;
|
68 | result: any;
|
69 | implicitTypes: Type[];
|
70 | }
|
71 |
|
72 | export interface DumpOptions {
|
73 |
|
74 | indent?: number | undefined;
|
75 |
|
76 | noArrayIndent?: boolean | undefined;
|
77 |
|
78 | skipInvalid?: boolean | undefined;
|
79 |
|
80 | flowLevel?: number | undefined;
|
81 |
|
82 | styles?: { [x: string]: any } | undefined;
|
83 |
|
84 | schema?: Schema | undefined;
|
85 |
|
86 | sortKeys?: boolean | ((a: any, b: any) => number) | undefined;
|
87 | /** set max line width. (default: 80) */
|
88 | lineWidth?: number | undefined;
|
89 | /** if true, don't convert duplicate objects into references (default: false) */
|
90 | noRefs?: boolean | undefined;
|
91 | /** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */
|
92 | noCompatMode?: boolean | undefined;
|
93 | /**
|
94 | * if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
|
95 | * Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false).
|
96 | */
|
97 | condenseFlow?: boolean | undefined;
|
98 | /** strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters. (default: `'`) */
|
99 | quotingType?: "'" | '"' | undefined;
|
100 | /** if true, all non-key strings will be quoted even if they normally don't need to. (default: false) */
|
101 | forceQuotes?: boolean | undefined;
|
102 | /** callback `function (key, value)` called recursively on each key/value in source object (see `replacer` docs for `JSON.stringify`). */
|
103 | replacer?: ((key: string, value: any) => any) | undefined;
|
104 | }
|
105 |
|
106 | export interface TypeConstructorOptions {
|
107 | kind?: 'sequence' | 'scalar' | 'mapping' | undefined;
|
108 | resolve?: ((data: any) => boolean) | undefined;
|
109 | construct?: ((data: any, type?: string) => any) | undefined;
|
110 | instanceOf?: object | undefined;
|
111 | predicate?: ((data: object) => boolean) | undefined;
|
112 | represent?: ((data: object) => any) | { [x: string]: (data: object) => any } | undefined;
|
113 | representName?: ((data: object) => any) | undefined;
|
114 | defaultStyle?: string | undefined;
|
115 | multi?: boolean | undefined;
|
116 | styleAliases?: { [x: string]: any } | undefined;
|
117 | }
|
118 |
|
119 | export interface SchemaDefinition {
|
120 | implicit?: Type[] | undefined;
|
121 | explicit?: Type[] | undefined;
|
122 | }
|
123 |
|
124 | /** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
125 | export let FAILSAFE_SCHEMA: Schema;
|
126 | /** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
127 | export let JSON_SCHEMA: Schema;
|
128 | /** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */
|
129 | export let CORE_SCHEMA: Schema;
|
130 | /** all supported YAML types */
|
131 | export let DEFAULT_SCHEMA: Schema;
|
132 |
|
133 | export interface Mark {
|
134 | buffer: string;
|
135 | column: number;
|
136 | line: number;
|
137 | name: string;
|
138 | position: number;
|
139 | snippet: string;
|
140 | }
|
141 |
|
142 | export class YAMLException extends Error {
|
143 | constructor(reason?: string, mark?: Mark);
|
144 |
|
145 | toString(compact?: boolean): string;
|
146 |
|
147 | name: string;
|
148 |
|
149 | reason: string;
|
150 |
|
151 | message: string;
|
152 |
|
153 | mark: Mark;
|
154 | }
|
155 |
|
\ | No newline at end of file |