jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 216 forks source link

Use journaling and implement cache for async backends internally. #342

Closed james-pre closed 1 year ago

james-pre commented 1 year ago

Currently, to use sync functions with an async backend, one must use AsyncMirror .

I propose (in conjunction with #338) async backends be updated to work similar to this example:

class AsyncFS <SyncBackend, AsyncBackend> {
  //pretty much AsyncMirror, internally handle sync/async ops but with backends
}

IndexedDB:

import AsyncFS
import InMemoryBackend

class IndexedDBBackend implements Backend {
    ...
}

export class IndexedDB extends AsyncFS<InMemeoryBackend, IndexedDBBackend> {
    ...
}

With this, the end user can just treat it as synchronous.

Note that this should be worked on after #341

james-pre commented 1 year ago

May or may not be done as part of #338