Last active
October 20, 2022 07:52
-
-
Save rettuce/4522a3a8c06e2f4aaae61d7cb289b7b0 to your computer and use it in GitHub Desktop.
Revisions
-
rettuce revised this gist
Oct 20, 2022 . No changes.There are no files selected for viewing
-
rettuce revised this gist
Oct 20, 2022 . No changes.There are no files selected for viewing
-
rettuce created this gist
Oct 20, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ fileSave( output_obj:Object ) { let saveFileOptions = { suggestedName: "xxxxxx.json", types: [ { description: "JSON Files", accept: { "application/json": [".json"], }, }, ], }; (async () => { let blob = new Blob([JSON.stringify(output_obj, null, " ")], { type: "application/json", }); const handle = await window.showSaveFilePicker(saveFileOptions); await this.writeFile(handle, blob); console.log("save comp!!"); })(); } async writeFile(fileHandle, contents) { const writable = await fileHandle.createWritable(); await writable.write(contents); await writable.close(); }