-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.d.ts
103 lines (83 loc) · 3.08 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
102
103
import {Buffer} from 'node:buffer';
import {PassThrough as PassThroughStream} from 'node:stream';
import {ZlibOptions} from 'node:zlib';
export type Options = ZlibOptions;
export interface GzipSizeStream extends PassThroughStream {
/**
Contains the gzip size of the stream after it is finished. Since this happens asynchronously, it is recommended you use the `gzip-size` event instead.
*/
gzipSize?: number;
addListener(event: 'gzip-size', listener: (size: number) => void): this;
addListener(
event: string | symbol,
listener: (...args: any[]) => void
): this;
on(event: 'gzip-size', listener: (size: number) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: 'gzip-size', listener: (size: number) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: 'gzip-size', listener: (size: number) => void): this;
removeListener(
event: string | symbol,
listener: (...args: any[]) => void
): this;
off(event: 'gzip-size', listener: (size: number) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: 'gzip-size', size: number): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
prependListener(event: 'gzip-size', listener: (size: number) => void): this;
prependListener(
event: string | symbol,
listener: (...args: any[]) => void
): this;
prependOnceListener(
event: 'gzip-size',
listener: (size: number) => void
): this;
prependOnceListener(
event: string | symbol,
listener: (...args: any[]) => void
): this;
}
/**
Get the gzipped size of a string or buffer.
@returns The gzipped size of `input`.
@example
```
import {gzipSize} from 'gzip-size';
const text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.';
console.log(text.length);
//=> 191
console.log(await gzipSize(text));
//=> 78
```
*/
export function gzipSize(input: string | Buffer, options?: Options): Promise<number>;
/**
Synchronously get the gzipped size of a string or buffer.
@returns The gzipped size of `input`.
@example
```
import {gzipSizeSync} from 'gzip-size';
const text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.';
console.log(text.length);
//=> 191
console.log(gzipSizeSync(text));
//=> 78
```
*/
export function gzipSizeSync(input: string | Buffer, options?: Options): number;
/**
Get the gzipped size of a file.
@returns The size of the file.
*/
export function gzipSizeFromFile(filePath: string, options?: Options): Promise<number>;
/**
Synchronously get the gzipped size of a file.
@returns The size of the file.
*/
export function gzipSizeFromFileSync(filePath: string, options?: Options): number;
/**
@returns A stream that emits a `gzip-size` event and has a `gzipSize` property.
*/
export function gzipSizeStream(options?: Options): GzipSizeStream;