-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.d.ts
57 lines (51 loc) · 2.27 KB
/
main.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
declare module 'vdf-parser' {
interface VDFParseOptions {
/**
* Attempt to automatically convert numbers and booleans to their correct types, defaults to true
* @default true
*/
types: boolean;
/**
* Arrayify the values if they appear multiple times.
* Enabled by default, because Source does support multiple values with the same key (as separate entries).
* One may want to disable it if they expect a single value and their code is not prepared for different cases.
* In such case, the existing text value would be replaced with the new one, and existing object patched with the new values.
* @default true
*/
arrayify: boolean;
/**
* If defined, conditionals will be taken into account while parsing the VDF.
* Provide a list of defined conditionals without leading dollar sign and any found conditionals will be validated against this list.
* If you provide an empty array, everything requiring any conditional defined will be dropped.
* Conditions in VDF are processed from left to right.
* See README and test.js for examples of usage.
*/
conditionals?: string[];
}
interface VDFStringifyOptions {
/**
* Add indentation to the resulting text, defaults to false
* @default false
*/
pretty: boolean;
/**
* Indent with the following characters, defaults to a tabulator, requires "pretty" to be set to true
* @default "\t"
*/
indent: string;
}
/**
* Parse a VDF string into a JavaScript object
* @param text VDF text
* @param options Parsing options. Accepts a boolean for backwards compatibility ("types" option defaulting to true)
* @returns Parsed object
*/
export function parse<T>(text: string, options?: VDFParseOptions | boolean): T;
/**
* Parse a JavaScript object into a VDF string
* @param obj The object to stringify
* @param options Parsing options. Accepts a boolean for backwards compatibility ("pretty" option defaulting to false)
* @returns VDF string
*/
export function stringify(obj: object, options?: VDFStringifyOptions | boolean): string;
}