Skip to content

Commit

Permalink
Revert change from storage classes
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Hinek <[email protected]>
  • Loading branch information
frankhinek committed Apr 21, 2023
1 parent 9786d34 commit 6a95eca
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/did/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export class DidManager {
return this.#store.get(id);
}

async remove(id) {
this.#store.remove(id);
async delete(id) {
this.#store.delete(id);
}

async set(id, value) {
Expand Down
2 changes: 1 addition & 1 deletion src/did/web5-did.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class Web5Did {
clear: () => this.#didManager.clear(),
exists: (...args) => this.#didManager.exists(...args),
get: (...args) => this.#didManager.get(...args),
remove: (...args) => this.#didManager.remove(...args),
delete: (...args) => this.#didManager.delete(...args),
set: (...args) => this.#didManager.set(...args),
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/storage/local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class LocalStorage extends Storage {
localStorage.setItem(key, JSON.stringify(value));
}

async remove(key) {
async delete(key) {
localStorage.removeItem(key);
}

Expand Down
4 changes: 2 additions & 2 deletions src/storage/memory-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export class MemoryStorage extends Storage {

if (Number.isFinite(options?.timeout)) {
const timeout = setTimeout(() => {
this.remove(key);
this.delete(key);
}, options.timeout);
this.#timeoutForKey.set(key, timeout);
}
}

async remove(key) {
async delete(key) {
this.#dataForKey.delete(key);

clearTimeout(this.#timeoutForKey.get(key));
Expand Down
2 changes: 1 addition & 1 deletion src/storage/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Storage {
throw 'subclass must override';
}

async remove(_key) {
async delete(_key) {
throw 'subclass must override';
}

Expand Down
6 changes: 3 additions & 3 deletions tests/storage/memory-storage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ describe('MemoryStorage', async () => {
expect(valueInCache).to.equal('bValue');
});

it('should remove specified entry', async () => {
it('should delete specified entry', async () => {
const storage = new MemoryStorage();

await storage.set('key1', 'aValue');
await storage.set('key2', 'aValue');
await storage.set('key3', 'aValue');

await storage.remove('key1');
await storage.delete('key1');

let valueInCache = await storage.get('key1');
expect(valueInCache).to.be.undefined;
valueInCache = await storage.get('key2');
expect(valueInCache).to.equal('aValue');
});

it('should remove all entries after `clear()`', async () => {
it('should delete all entries after `clear()`', async () => {
const storage = new MemoryStorage();

await storage.set('key1', 'aValue');
Expand Down

0 comments on commit 6a95eca

Please sign in to comment.