Initial Commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { DriveLike } from "@suaveplan/vault";
|
||||
|
||||
/** Minimal in-memory `DriveLike` for tests. */
|
||||
export function createMemoryDrive(): DriveLike {
|
||||
const store = new Map<string, Uint8Array>();
|
||||
return {
|
||||
async read(path) {
|
||||
const bytes = store.get(path);
|
||||
if (bytes === undefined)
|
||||
throw new Error(`memory-drive: missing path ${path}`);
|
||||
return bytes;
|
||||
},
|
||||
async write(path, data) {
|
||||
store.set(path, data);
|
||||
},
|
||||
async delete(path) {
|
||||
return store.delete(path);
|
||||
},
|
||||
async exists(path) {
|
||||
return store.has(path);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user