-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.d.ts
37 lines (28 loc) · 845 Bytes
/
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
import {type ImageOptions} from 'ansi-escapes';
export class UnsupportedTerminalError extends Error {
readonly name: 'UnsupportedTerminalError';
constructor();
}
export type Options<FallbackType = unknown> = {
/**
Enables you to do something else when the terminal doesn't support images.
@default () => throw new UnsupportedTerminalError()
*/
readonly fallback?: () => FallbackType;
} & ImageOptions;
/**
Get the image as a `string` that you can log manually.
@param image - File path to an image or an image as a buffer.
@example
```
import terminalImage from 'term-img';
function fallback() {
// Do something else when not supported
}
terminalImage('unicorn.jpg', {fallback});
```
*/
export default function terminalImage<FallbackType>(
image: string | Uint8Array,
options?: Options<FallbackType>
): string | FallbackType;