UNPKG

browser-nativefs

Version:

Native File System API with legacy fallback in the browser.

2 lines 440 B
// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. export default async(e,t={},i=null)=>{t.fileName=t.fileName||"Untitled";const a={};t.mimeTypes?(t.mimeTypes.push(e.type),t.mimeTypes.map((e=>{a[e]=t.extensions||[]}))):a[e.type]=t.extensions||[],i=i||await window.showSaveFilePicker({types:[{description:t.description||"",accept:a}]});const s=await i.createWritable();return await s.write(e),await s.close(),i};