eligrey / eligrey/FileSaver.js
Add stripped down / Modern version
- Dominant language
- JavaScript
- Stars
- 22k
- Forks
- 4.3k
- PR merge metrics
- No merged PRs in 30d
Description
i found this lib via stackoverflow but i luckely dont need to support ancient browsers of times from the dinosaurs so i was able to strip it down to the most important parts ;) works in chrome and firefox ^^
```js
// stripped down version of https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js#L81-L108
/**
* @param {Blob} blob
* @param {string} name
*/
export const saveAs = (blob, name) => {
// Namespace is used to prevent conflict w/ Chrome Poper Blocker extension (Issue https://github.com/eligrey/FileSaver.js/issues/561)
const a = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
a.download = name
a.rel = 'noopener'
a.href = URL.createObjectURL(blob)
setTimeout(() => URL.revokeObjectURL(a.href), 40 /* sec */ * 1000)
setTimeout(() => a.click(), 0)
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.