mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
12 lines
361 B
TypeScript
12 lines
361 B
TypeScript
export const saveFile = (json: unknown, filename: string, extension: string) => {
|
|
const anchor = document.createElement('a');
|
|
anchor.href = URL.createObjectURL(
|
|
new Blob([JSON.stringify(json, null, 2)], {
|
|
type: 'text/plain'
|
|
})
|
|
);
|
|
anchor.download = 'emsesp_' + filename + extension;
|
|
anchor.click();
|
|
URL.revokeObjectURL(anchor.href);
|
|
};
|