-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.d.ts
78 lines (60 loc) · 2.22 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
import type {Readable as ReadableStream} from 'node:stream';
declare const isProgressive: {
/**
Checks if an `Uint8Array` contains a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html).
@param buffer - The buffer of a JPEG image. Must be at least `65535` bytes when the file is larger than that.
@returns Whether the `buffer` is a progressive JPEG image.
@example
```
import {promisify} from 'node:util';
import {readFile} from 'node:fs/promises';
import isProgressive from 'is-progressive';
const buffer = await readFile('baseline.jpg');
console.log(await isProgressive.buffer(buffer));
//=> false
```
*/
buffer(buffer: Uint8Array): boolean;
/**
Checks if a `stream.Readable` produces a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html).
@param stream - A data stream with a JPEG image.
@returns Whether the `stream` is a progressive JPEG image.
@example
```
// Check if a remote JPEG image is progressive without downloading the whole file
import https from 'node:https';
import isProgressive from 'is-progressive';
const url = 'https://raw.githubusercontent.com/sindresorhus/is-progressive/main/fixture/progressive.jpg';
https.get(url, async response => {
console.log(await isProgressive.stream(response));
//=> true
});
```
*/
stream(stream: ReadableStream): Promise<boolean>;
/**
Checks if a file is a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html).
@param filePath - The file path to the image.
@returns Whether the file at the `filePath` is a progressive JPEG image.
@example
```
import isProgressive from 'is-progressive';
console.log(await isProgressive.file('baseline.jpg'));
//=> false
```
*/
file(filePath: string): Promise<boolean>;
/**
Synchronously checks if a file is a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html).
@param filePath - The file path to the image.
@returns Whether the file at the `filePath` is a progressive JPEG.
@example
```
import isProgressive from 'is-progressive';
isProgressive.fileSync('progressive.jpg');
//=> true
```
*/
fileSync(filePath: string): boolean;
};
export default isProgressive;