-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
101 lines (78 loc) · 3 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
declare module 'json-mangler' {
/**
* Compressor class used for compressing JSON objects.
*/
export class Compressor {
/**
* Compressor class used for compressing JSON objects.
* @param schema A schema for the JSON objects that will be compressed with this compressor instance.
*/
constructor(schema: Object);
/**
* Returns the generated mappings.
*/
readonly mappings: string;
/**
* Compresses a JSON object.
* @param json The object to compress.
* @param noClone Will avoid cloning the object (will be faster but mutates the original object by reference, defaults to false).
* @param calcInfo Will calculate the compression info (will make the compression slower, defaults to false).
*/
compress(json: Object, noClone?: boolean, calcInfo?: boolean): CompressionResult;
}
/**
* Decompressor class used for decompressing JSON objects.
*/
export class Decompressor {
/**
* Decompressor class used for decompressing JSON objects.
* @param mappings A mappings string for the JSON objects that will be decompressed with this decompressor instance.
*/
constructor(mappings: string);
/**
* Returns the mappings being used.
*/
readonly mappings: string;
/**
* Decompresses a compressed JSON object.
* @param json The object to decompress.
* @param noClone Will avoid cloning the object (will be faster but mutates the original object by reference, defaults to false).
* @param calcInfo Will calculate the decompression info (will make the decompression slower, defaults to false).
*/
decompress(json: Object, noClone?: boolean, calcInfo?: boolean): DecompressionResult;
}
interface CompressionInfo {
/** Original size of the JSON object in bytes. */
originalSize: number;
/** Size of the compressed JSON object in bytes. */
newSize: number;
/** The size difference of the original and the final objects in bytes. */
diff: number;
/** The time of the compression in milliseconds. */
time: number;
}
interface DecompressionInfo {
/** Original size of the compressed JSON object in bytes. */
originalSize: number;
/** Size of the decompressed JSON object in bytes. */
newSize: number;
/** The size difference of the original and the final objects in bytes. */
diff: number;
/** The time of the decompression in milliseconds. */
time: number;
}
interface CompressionResult {
/** The compressed JSON object. */
compressed: Object;
/** The generated mappings used for decompressing the object back to its original form. */
mappings: string;
/** The compression information (will be null if calcInfo was false at the time of compression). */
info?: CompressionInfo;
}
interface DecompressionResult {
/** The decompressed JSON object. */
decompressed: Object;
/** The decompression information (will be null if calcInfo was false at the time of decompression). */
info?: DecompressionInfo;
}
}