mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
Merge pull request #244 from BartNetJS/patch-1
check for window.localStorage
This commit is contained in:
commit
5f0f96664f
13
gun.js
13
gun.js
@ -1171,7 +1171,18 @@
|
||||
s.put = function(key, val, cb){ try{ store.setItem(key, Gun.text.ify(val)) }catch(e){if(cb)cb(e)} }
|
||||
s.get = function(key, cb){ /*setTimeout(function(){*/ try{ cb(null, Gun.obj.ify(store.getItem(key) || null)) }catch(e){cb(e)} /*},1)*/}
|
||||
s.del = function(key){ return store.removeItem(key) }
|
||||
var store = window.localStorage || {setItem: function(){}, removeItem: function(){}, getItem: function(){}};
|
||||
// Feature detect + local reference
|
||||
var storage;
|
||||
var fail;
|
||||
var uid;
|
||||
try {
|
||||
uid = new Date;
|
||||
(storage = window.localStorage).setItem(uid, uid);
|
||||
fail = storage.getItem(uid) != uid;
|
||||
storage.removeItem(uid);
|
||||
fail && (storage = false);
|
||||
} catch (exception) {}
|
||||
var store = (storage && window.localStorage) || {setItem: function(){}, removeItem: function(){}, getItem: function(){}};
|
||||
exports.store = s;
|
||||
}.bind(this || module)(Tab));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user