(fileName: string, text: string)
| 63 | } |
| 64 | |
| 65 | export const downloadFileFromText = (fileName: string, text: string) => { |
| 66 | const file = new Blob([text], { type: 'data:text/plain;charset=utf-8' }) |
| 67 | |
| 68 | const element = document.createElement('a') |
| 69 | const url = URL.createObjectURL(file) |
| 70 | element.href = url |
| 71 | element.download = fileName |
| 72 | document.body.appendChild(element) |
| 73 | element.click() |
| 74 | Promise.resolve().then(() => { |
| 75 | document.body.removeChild(element) |
| 76 | window.URL.revokeObjectURL(url) |
| 77 | }) |
| 78 | } |
nothing calls this directly
no test coverage detected