zapier-async-storage
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _destroyDatabase = require('./utils/destroyDatabase'); | ||
var _destroyDatabase2 = _interopRequireDefault(_destroyDatabase); | ||
var _constants = require('./constants'); | ||
@@ -278,2 +282,6 @@ | ||
if (options.enableLogging) { | ||
console.info('Closed connection to: ', dbName); | ||
} | ||
resolve(); | ||
@@ -284,2 +292,11 @@ }); | ||
// Destroys the database instance | ||
function destroy() { | ||
return databaseReadyPromise.then(function (dbInstance) { | ||
dbInstance.close(); | ||
return (0, _destroyDatabase2.default)(dbName, options); | ||
}); | ||
} | ||
return { | ||
@@ -295,3 +312,4 @@ isReady: databaseReadyPromise, | ||
iterate: _lodash2.default.partial(iterate, storeName), | ||
close: close | ||
close: close, | ||
destroy: destroy | ||
}; | ||
@@ -298,0 +316,0 @@ } |
@@ -217,2 +217,43 @@ 'use strict'; | ||
var destroyDatabase = function destroyDatabase(databaseName) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return new Promise(function (resolve, reject) { | ||
var _opts$enableLogging = opts.enableLogging, | ||
enableLogging = _opts$enableLogging === undefined ? false : _opts$enableLogging; | ||
try { | ||
var req = getIndexedDB().deleteDatabase(databaseName); | ||
req.onsuccess = function () { | ||
if (enableLogging) { | ||
console.info('Successfully removed IndexedDB: ', databaseName); | ||
} | ||
resolve(true); | ||
}; | ||
req.onerror = function (err) { | ||
if (enableLogging) { | ||
console.warn('Unable to delete IndexedDB: ', databaseName); | ||
} | ||
reject(err); | ||
}; | ||
req.onblocked = function (err) { | ||
if (enableLogging) { | ||
console.warn('Blocked attempting to delete IndexedDB: ', databaseName); | ||
} | ||
reject(err); | ||
}; | ||
} catch (err) { | ||
if (enableLogging) { | ||
console.warn('Unable to initialize IndexedDB deletion: ', databaseName); | ||
} | ||
reject(err); | ||
} | ||
}); | ||
}; | ||
var indexedDB = getIndexedDB(); | ||
@@ -468,2 +509,6 @@ | ||
if (options.enableLogging) { | ||
console.info('Closed connection to: ', dbName); | ||
} | ||
resolve(); | ||
@@ -474,2 +519,11 @@ }); | ||
// Destroys the database instance | ||
function destroy() { | ||
return databaseReadyPromise.then(function (dbInstance) { | ||
dbInstance.close(); | ||
return destroyDatabase(dbName, options); | ||
}); | ||
} | ||
return { | ||
@@ -485,3 +539,4 @@ isReady: databaseReadyPromise, | ||
iterate: _.partial(iterate, storeName), | ||
close: close | ||
close: close, | ||
destroy: destroy | ||
}; | ||
@@ -491,2 +546,3 @@ } | ||
exports.createStorageInstance = createInstance; | ||
exports.destroyDatabase = destroyDatabase; | ||
exports.getIndexedDB = getIndexedDB; |
{ | ||
"name": "zapier-async-storage", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Minimalist wrapper for IndexedDB", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35190
15
992