1 | // Type definitions for FileSaver.js 2.0
|
2 | // Project: https://github.com/eligrey/FileSaver.js/
|
3 | // Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
4 | // Daniel Roth <https://github.com/DaIgeb>
|
5 | // Chris Barr <https://github.com/chrismbarr>
|
6 | // HitkoDev <https://github.com/HitkoDev>
|
7 | // JounQin <https://github.com/JounQin>
|
8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
9 |
|
10 | declare namespace FileSaver {
|
11 | interface FileSaverOptions {
|
12 | /**
|
13 | * Automatically provide Unicode text encoding hints
|
14 | * @default false
|
15 | */
|
16 | autoBom: boolean;
|
17 | }
|
18 |
|
19 | /**
|
20 | * FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
|
21 | * @param data - The actual file data blob or URL.
|
22 | * @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
|
23 | * @param options - Optional FileSaver.js config
|
24 | */
|
25 | function saveAs(data: Blob | string, filename?: string, options?: FileSaverOptions): void;
|
26 |
|
27 | /**
|
28 | * FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
|
29 | * @param data - The actual file data blob or URL.
|
30 | * @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
|
31 | * @param disableAutoBOM - Optional & defaults to `true`. Set to `false` if you want FileSaver.js to automatically provide Unicode text encoding hints
|
32 | * @deprecated use `{ autoBom: false }` as the third argument
|
33 | */
|
34 | // tslint:disable-next-line:unified-signatures
|
35 | function saveAs(data: Blob | string, filename?: string, disableAutoBOM?: boolean): void;
|
36 | }
|
37 |
|
38 | declare global {
|
39 | const saveAs: typeof FileSaver.saveAs;
|
40 |
|
41 | interface Window {
|
42 | saveAs: typeof FileSaver.saveAs;
|
43 | }
|
44 | }
|
45 |
|
46 | export = FileSaver;
|