UNPKG

3.51 kBTypeScriptView Raw
1// Type definitions for js-yaml 3.5.2
2// Project: https://github.com/nodeca/js-yaml
3// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Sebastian Clausen <https://github.com/sclausen>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6declare namespace jsyaml {
7 export function safeLoad(str: string, opts?: LoadOptions): any;
8 export function load(str: string, opts?: LoadOptions): any;
9
10 export class Type implements TypeConstructorOptions {
11 constructor(tag: string, opts?: TypeConstructorOptions);
12 tag: string;
13 }
14 export class Schema {
15 constructor(definition: SchemaDefinition);
16 public static create(args: any[]): Schema;
17 }
18
19 export function safeLoadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): any;
20 export function loadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): any;
21
22 export function safeDump(obj: any, opts?: DumpOptions): string;
23 export function dump(obj: any, opts?: DumpOptions): string;
24
25 export interface LoadOptions {
26 // string to be used as a file path in error/warning messages.
27 filename?: string;
28 // makes the loader to throw errors instead of warnings.
29 strict?: boolean;
30 // specifies a schema to use.
31 schema?: any;
32 }
33
34 export interface DumpOptions {
35 // indentation width to use (in spaces).
36 indent?: number;
37 // do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types.
38 skipInvalid?: boolean;
39 // specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere
40 flowLevel?: number;
41 // Each tag may have own set of styles. - "tag" => "style" map.
42 styles?: Object;
43 // specifies a schema to use.
44 schema?: any;
45 // if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false)
46 sortKeys?: boolean | ((a: any, b: any) => number);
47 // set max line width. (default: 80)
48 lineWidth?: number;
49 // if true, don't convert duplicate objects into references (default: false)
50 noRefs?: boolean;
51 // 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)
52 noCompatMode?: boolean;
53 }
54
55 export interface TypeConstructorOptions {
56 kind?: string;
57 resolve?: Function;
58 construct?: Function;
59 instanceOf?: Object;
60 predicate?: string;
61 represent?: Function;
62 defaultStyle?: string;
63 styleAliases?: Object;
64 }
65
66 export interface SchemaDefinition {
67 implicit?: any[];
68 explicit?: any[];
69 include?: any[];
70 }
71
72 // only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
73 export var FAILSAFE_SCHEMA: any;
74 // only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
75 export var JSON_SCHEMA: any;
76 // same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923
77 export var CORE_SCHEMA: any;
78 // all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/
79 export var DEFAULT_SAFE_SCHEMA: any;
80 // all supported YAML types.
81 export var DEFAULT_FULL_SCHEMA: any;
82 export var MINIMAL_SCHEMA: any;
83 export var SAFE_SCHEMA: any;
84
85 export class YAMLException extends Error {
86 constructor(reason?: any, mark?: any);
87 toString(compact?: boolean): string;
88 }
89}
90
91export = jsyaml;
92export as namespace jsyaml;
93
\No newline at end of file