diff --git a/src/IndexedDB.ts b/src/IndexedDB.ts index 50d7531..08aa7bc 100644 --- a/src/IndexedDB.ts +++ b/src/IndexedDB.ts @@ -26,6 +26,10 @@ export class IndexedDBTransaction extends AsyncTransaction { this._idb = tx.objectStore(store.name); } + public async keys(): Promise> { + return (await wrap(this._idb.getAllKeys())).filter(k => typeof k == 'string').map(k => BigInt(k)); + } + public get(key: Ino): Promise { return wrap(this._idb.get(key.toString())); } diff --git a/src/Storage.ts b/src/Storage.ts index 5adbe7d..b5815d7 100644 --- a/src/Storage.ts +++ b/src/Storage.ts @@ -26,6 +26,10 @@ export class WebStorageStore implements Store, SimpleSyncStore { return new SimpleTransaction(this); } + public keys(): Iterable { + return Object.keys(this.storage).map(k => BigInt(k)); + } + public get(key: Ino): Uint8Array | undefined { const data = this.storage.getItem(key.toString()); if (typeof data != 'string') {