file-saver: Allow saving files directly (#16045)

As documented on https://github.com/eligrey/FileSaver.js/ saving a file
without using the Blob object should be possible
This commit is contained in:
DaIgeb
2017-04-26 20:43:48 +02:00
committed by Sheetal Nandi
parent 2971c4624a
commit ecd2bdb304
2 changed files with 18 additions and 1 deletions

View File

@@ -19,3 +19,12 @@ function testSaveAs() {
saveAs(data, filename, disableAutoBOM);
}
/**
* @summary Test for "saveAs" function.
*/
function testSaveAsFile() {
const data = new File(["Hello, world!"], "hello world.txt" ,{type: "text/plain;charset=utf-8"});
saveAs(data);
}

View File

@@ -1,6 +1,6 @@
// Type definitions for FileSaver.js
// Project: https://github.com/eligrey/FileSaver.js/
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, Daniel Roth <https://github.com/DaIgeb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@@ -28,6 +28,14 @@ interface FileSaver {
*/
disableAutoBOM?: boolean
): void
(
/**
* @summary File.
* @type {File}
*/
data: File
): void
}
declare var saveAs: FileSaver;