react-klasha
Version:
This is an reactJS library for implementing klasha payment gateway
35 lines (30 loc) • 895 B
text/typescript
/*
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: string) => {
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();
};
});
};