Check JSON support just once

Two separate modules (localStorage & websockets) ensured JSON was
globally defined. Since only one is needed to alert the user, the
other has been removed.
This commit is contained in:
Jesse Gibson 2016-12-12 16:10:39 -07:00
parent bb65acab10
commit 30fe844cab

5
gun.js
View File

@ -2142,8 +2142,7 @@
})(require, './api');
;require(function(module){
if(typeof JSON === 'undefined'){ throw new Error("Include JSON first: ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js") } // for old IE use
if(typeof Gun === 'undefined'){ return } // TODO: localStorage is Browser only. But it would be nice if it could somehow plugin into NodeJS compatible localStorage APIs?
if(typeof Gun === 'undefined'){ return } // TODO: localStorage is Browser only. But it would be nice if it could somehow plugin into NodeJS compatible localStorage APIs?
var root, noop = function(){};
if(typeof window !== 'undefined'){ root = window }
@ -2448,7 +2447,7 @@
var peers = gun.Back('opt.peers') || {};
// Validate.
if (Gun.obj.empty(peers) || !WebSocket) {
if (Gun.obj.empty(peers)) {
return;
}