web/storage: add memory storage and init() function

This commit is contained in:
jj
2025-04-30 17:55:57 +00:00
parent be4e7e2d7d
commit ce4ded64a2
3 changed files with 107 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import type { AbstractStorage } from "./storage";
import { MemoryStorage } from "./memory";
import { OPFSStorage } from "./opfs";
export function init(expectedSize?: number): Promise<AbstractStorage> {
if (OPFSStorage.isAvailable()) {
return OPFSStorage.init();
}
if (MemoryStorage.isAvailable()) {
return MemoryStorage.init(expectedSize || 0);
}
throw "no storage method is available";
}