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