1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-22 07:16:38 +02:00
keeweb/app/scripts/util/file-saver.js
2019-01-06 15:38:03 +01:00

23 lines
509 B
JavaScript

const timeouts = require('../const/timeouts');
const FileSaver = {
saveAs(blob, name) {
const link = document.createElement('a');
link.download = name;
link.rel = 'noopener';
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => {
URL.revokeObjectURL(link.href);
}, timeouts.LinkDownloadRevoke);
}
};
module.exports = FileSaver;