12345678910111213141516171819202122232425262728293031 |
- /*
- Copyright 2018 Google LLC
- Use of this source code is governed by an MIT-style
- license that can be found in the LICENSE file or at
- https://opensource.org/licenses/MIT.
- */
- import '../_version.js';
- /**
- * Deletes the database.
- * Note: this is exported separately from the DBWrapper module because most
- * usages of IndexedDB in workbox dont need deleting, and this way it can be
- * reused in tests to delete databases without creating DBWrapper instances.
- *
- * @param {string} name The database name.
- * @private
- */
- export const deleteDatabase = async (name) => {
- await new Promise((resolve, reject) => {
- const request = indexedDB.deleteDatabase(name);
- request.onerror = () => {
- reject(request.error);
- };
- request.onblocked = () => {
- reject(new Error('Delete blocked'));
- };
- request.onsuccess = () => {
- resolve();
- };
- });
- };
|