UNPKG

browser-nativefs

Version:

Native File System API with legacy fallback in the browser.

2 lines 569 B
// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. const e=async(t,r,i=t.name)=>{const a=[],s=[];for await(const n of t.getEntries()){const t=`${i}/${n.name}`;n.isFile?s.push(n.getFile().then((e=>Object.defineProperty(e,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>t})))):n.isDirectory&&r&&a.push(e(n,r,t))}return[...(await Promise.all(a)).flat(),...await Promise.all(s)]};export default async(t={})=>{t.recursive=t.recursive||!1;const r=await window.chooseFileSystemEntries({type:"open-directory"});return e(r,t.recursive)};