-
Notifications
You must be signed in to change notification settings - Fork 43
/
index.d.ts
58 lines (49 loc) · 1.69 KB
/
index.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
58
import { Transform } from "stream";
type JsonValue = boolean | number | string | JsonMap | JsonArray | Date
type JsonArray = JsonValue[]
type AnyJson = boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]
interface JsonMap {
[key: string]: AnyJson;
}
interface ParseOptions {
/**
* The amount text to parser per pass through the event loop. Defaults to 40kb (`40000`).
*/
blocksize: number
}
interface FuncParse {
/**
* Synchronously parse a TOML string and return an object.
*/
<Parsed = JsonMap>(toml: string): Parsed
/**
* Asynchronously parse a TOML string and return a promise of the resulting object.
*/
async <Parsed = JsonMap>(toml: string, options?: ParseOptions): Promise<Parsed>
/**
* Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
*/
stream <Parsed = JsonMap>(readable: NodeJS.ReadableStream): Promise<Parsed>
stream (): Transform
}
interface FuncStringify {
/**
* Serialize an object as TOML.
*
* If an object `TOML.stringify` is serializing has a `toJSON` method
* then it will call it to transform the object before serializing it.
* This matches the behavior of JSON.stringify.
*
* The one exception to this is that `toJSON` is not called for `Date` objects
* because JSON represents dates as strings and TOML can represent them natively.
*
* `moment` objects are treated the same as native `Date` objects, in this respect.
*/
(obj: JsonMap): string
/**
* Serialize a value as TOML would. This is a fragment and not a complete valid TOML document.
*/
value (any: AnyJson): string
}
export const parse: FuncParse
export const stringify: FuncStringify