Added this check on ine 2151 to prevent an error when using ESM

This commit is contained in:
joedakroub 2020-04-10 10:48:01 -04:00
parent 17f90d6d10
commit 46b0fb6dc5

8
gun.js
View File

@ -987,7 +987,7 @@
if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window }
try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){}
module.exports = Gun;
(Gun.window||'').console = (Gun.window||'').console || {log: function(){}};
(C = console).only = function(i, s){ return (C.only.i && i === C.only.i && C.only.i++) && (C.log.apply(C, arguments) || s) };
@ -2148,7 +2148,7 @@
var message, loop;
function each(peer){ mesh.say(message, peer) }
var say = mesh.say = function(msg, peer){
if(this.to){ this.to.next(msg) } // compatible with middleware adapters.
if(this && this.to){ this.to.next(msg) } // compatible with middleware adapters.
if(!msg){ return false }
var id, hash, tmp, raw;
var DBG = msg.DBG, S; if(!peer){ S = +new Date ; DBG && (DBG.y = S) }
@ -2314,7 +2314,7 @@
});
root.on('bye', function(peer, tmp){
peer = opt.peers[peer.id || peer] || peer;
peer = opt.peers[peer.id || peer] || peer;
this.to.next(peer);
peer.bye? peer.bye() : (tmp = peer.wire) && tmp.close && tmp.close();
Type.obj.del(opt.peers, peer.id);
@ -2429,4 +2429,4 @@
var noop = function(){};
})(USE, './adapters/websocket');
}());
}());