Skip to content

Commit

Permalink
feat: delete CacheStorage.delete() API (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aui authored Apr 19, 2024
1 parent 5247000 commit c7f91c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-dryers-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@web-widget/shared-cache": minor
---

Delete `CacheStorage.delete()` API.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ The `CacheStorage` class implements [CacheStorage](https://developer.mozilla.org

Returns a Promise that resolves to the Cache object matching the cacheName (a new cache is created if it doesn't already exist.) This method follows the specification.

### `delete`
### ~~`delete`~~

Finds the Cache object matching the cacheName, and if found, deletes the Cache object and returns a Promise that resolves to true. If no Cache object is found, it resolves to false. This method follows the specification.
`SharedCache` didn't implement it.

### ~~`match`~~

Expand Down
16 changes: 3 additions & 13 deletions src/cache-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,9 @@ export class SharedCacheStorage implements CacheStorage {
this.#options = options;
}

/**
* The delete() method of the CacheStorage interface finds the Cache object
* matching the cacheName, and if found, deletes the Cache object and returns
* a Promise that resolves to true. If no Cache object is found, it resolves
* to false.
* @param cacheName The name of the cache you want to delete.
*/
async delete(cacheName: string): Promise<boolean> {
const hasCache = this.#caches.has(cacheName);
if (hasCache) {
this.#caches.delete(cacheName);
}
return hasCache;
/** @private */
async delete(_cacheName: string): Promise<boolean> {
throw new Error('Not Implemented.');
}

/** @private */
Expand Down

0 comments on commit c7f91c9

Please sign in to comment.