web/storage: add memory storage and init() function
This commit is contained in:
15
web/src/lib/storage/index.ts
Normal file
15
web/src/lib/storage/index.ts
Normal 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";
|
||||
}
|
||||
Reference in New Issue
Block a user