diff --git a/lib/engine.js b/lib/engine.js index bb61f65..4f53eaf 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -33,7 +33,7 @@ var inMemoryStore = { } }; -function isSupportedNatively() { +var isSupportedNatively = (function() { try { if (!window.localStorage) return false; var key = uuid(); @@ -47,17 +47,17 @@ function isSupportedNatively() { // Can throw if localStorage is disabled return false; } -} +}()); function pickStorage() { - if (isSupportedNatively()) { + if (isSupportedNatively) { return window.localStorage; } // fall back to in-memory return inMemoryStore; } -function isReadSupportedNatively() { +var isReadSupportedNatively = (function() { try { if (!window.localStorage) return false; var key = window.localStorage.key(0); @@ -69,10 +69,10 @@ function isReadSupportedNatively() { // Can throw if localStorage is disabled return false; } -} +}()); function pickReclaimStorage() { - if (isReadSupportedNatively()) { + if (isSupportedNatively || isReadSupportedNatively) { return window.localStorage; } // fall back to in-memory