Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract quota exceeded testing to use an array #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lscache.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
// ECMAScript max Date (epoch + 1e8 days)
var maxDate = calculateMaxDate(expiryMilliseconds);

// Names to identify exceeded quota errors by
var quotaExceeded = ['QUOTA_EXCEEDED_ERR', 'NS_ERROR_DOM_QUOTA_REACHED', 'QuotaExceededError'];

var cachedStorage;
var cachedJSON;
var cacheBucket = '';
Expand Down Expand Up @@ -90,11 +93,7 @@

// Check to set if the error is us dealing with being out of space
function isOutOfSpace(e) {
return e && (
e.name === 'QUOTA_EXCEEDED_ERR' ||
e.name === 'NS_ERROR_DOM_QUOTA_REACHED' ||
e.name === 'QuotaExceededError'
);
return e && quotaExceeded.indexOf(e.name) !== -1;
}

// Determines if native JSON (de-)serialization is supported in the browser.
Expand Down