chrome-storage-local
Advanced tools
Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "chrome-storage-local", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Use the same api for chrome.storage.local as for localStorage.", | ||
@@ -5,0 +5,0 @@ "main": "storage.js", |
var storage; | ||
function noop() {} | ||
function getStorage() { | ||
try { | ||
return window.localStorage; | ||
} catch(e) { | ||
return { | ||
getItem: noop, | ||
setItem: noop, | ||
removeItem: noop, | ||
getAllKeys: noop | ||
}; | ||
} | ||
} | ||
if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local) { | ||
@@ -31,4 +46,4 @@ storage = { isChromeStorage: true }; | ||
} | ||
else storage = window.localStorage; | ||
else storage = getStorage(); | ||
module.exports = storage; |
1612
40