mirror of
https://github.com/amark/gun.git
synced 2025-06-05 21:56:51 +00:00
Merge pull request #936 from joedakroub/master
Fix for ES Modules when using a peer
This commit is contained in:
commit
ff99a4639d
8
gun.js
8
gun.js
@ -987,7 +987,7 @@
|
|||||||
if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window }
|
if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window }
|
||||||
try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){}
|
try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){}
|
||||||
module.exports = Gun;
|
module.exports = Gun;
|
||||||
|
|
||||||
(Gun.window||'').console = (Gun.window||'').console || {log: function(){}};
|
(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) };
|
(C = console).only = function(i, s){ return (C.only.i && i === C.only.i && C.only.i++) && (C.log.apply(C, arguments) || s) };
|
||||||
|
|
||||||
@ -2158,7 +2158,7 @@
|
|||||||
var message, loop;
|
var message, loop;
|
||||||
function each(peer){ mesh.say(message, peer) }
|
function each(peer){ mesh.say(message, peer) }
|
||||||
var say = mesh.say = function(msg, 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 }
|
if(!msg){ return false }
|
||||||
var id, hash, tmp, raw;
|
var id, hash, tmp, raw;
|
||||||
var DBG = msg.DBG, S; if(!peer){ S = +new Date ; DBG && (DBG.y = S) }
|
var DBG = msg.DBG, S; if(!peer){ S = +new Date ; DBG && (DBG.y = S) }
|
||||||
@ -2324,7 +2324,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
root.on('bye', function(peer, tmp){
|
root.on('bye', function(peer, tmp){
|
||||||
peer = opt.peers[peer.id || peer] || peer;
|
peer = opt.peers[peer.id || peer] || peer;
|
||||||
this.to.next(peer);
|
this.to.next(peer);
|
||||||
peer.bye? peer.bye() : (tmp = peer.wire) && tmp.close && tmp.close();
|
peer.bye? peer.bye() : (tmp = peer.wire) && tmp.close && tmp.close();
|
||||||
Type.obj.del(opt.peers, peer.id);
|
Type.obj.del(opt.peers, peer.id);
|
||||||
@ -2439,4 +2439,4 @@
|
|||||||
var noop = function(){};
|
var noop = function(){};
|
||||||
})(USE, './adapters/websocket');
|
})(USE, './adapters/websocket');
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user