Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Commit

Permalink
Add deleteAll (#13)
Browse files Browse the repository at this point in the history
* Add deleteAll

* Make semistandard happy.

* add test case

* PR Comments.
  • Loading branch information
telackey committed May 5, 2020
1 parent 38319b1 commit 007860c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/feed-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ export class FeedStore extends EventEmitter {
return descriptor.close();
}

/**
* Remove all descriptors from the indexDB.
*
* NOTE: This operation would not close the feeds.
*
* @returns {Promise<Promise[]>}
*/
async deleteAllDescriptors () {
return Promise.all(this.getDescriptors().map(({ path }) => this.deleteDescriptor(path)));
}

/**
* Remove a descriptor from the indexDB by the path.
*
Expand Down
6 changes: 6 additions & 0 deletions src/feed-store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,10 @@ describe('FeedStore', () => {
resolve();
}));
});

test('Delete all', async () => {
expect(feedStore.getDescriptors().length).toBe(2);
await feedStore.deleteAllDescriptors();
expect(feedStore.getDescriptors().length).toBe(0);
});
});

0 comments on commit 007860c

Please sign in to comment.