nova-ui/utilities/files.ts

12 lines
293 B
TypeScript
Raw Normal View History

2022-12-04 09:02:30 +03:00
import FileSaver from 'file-saver'
export function saveAsFile(text: string, name = '') {
try {
const data = new Blob([text], { type: 'text/plain;charset=utf-8' })
FileSaver.saveAs(data, `${name}.txt`)
} catch (err) {
console.error('saveAsFile has error:', err.message)
}
}