daedalOS/utils/filesystem.ts
2020-09-25 16:04:11 -07:00

26 lines
566 B
TypeScript

import type * as BrowserFS from 'browserfs';
import type { ListingObj } from '@/types/utils/filesystem';
export const writableJsonFs = (
path: string,
listingUrlOrObj: string | ListingObj
): { [key: string]: BrowserFS.FileSystemConfiguration } => ({
[path]: {
fs: 'OverlayFS',
options: {
readable: {
fs: 'XmlHttpRequest',
options: {
index: listingUrlOrObj
}
},
writable: {
fs: 'IndexedDB',
options: {
storeName: `browser-fs-cache (${path})`
}
}
}
}
});