let NodeJS be a browser-like peer

This commit is contained in:
Mark Nadal 2018-03-13 16:06:48 -07:00
parent 0b59be0345
commit 402c56d14b
5 changed files with 8 additions and 5 deletions

1
gun.js
View File

@ -545,6 +545,7 @@
return valid(v,k,n, at,env);
}
env.err = "Invalid value at '" + at.path.concat(k).join('.') + "'!";
if(Type.list.is(v)){ env.err += " Use `.set(item)` instead of an Array." }
}
function seen(env, at){
var arr = env.seen, i = arr.length, has;

2
gun.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -61,11 +61,11 @@ Gun.on('opt', function(ctx){
}
opt.WebSocket = opt.WebSocket || WebSocket;
var ws = opt.ws || {};
ws.server = ws.server || opt.web;
if(!opt.ws || !opt.ws.web){
if(ws.server && !ws.web){
var ws = opt.ws = opt.ws || {};
ws.server = ws.server || opt.web;
ws.path = ws.path || '/gun';
ws.web = new opt.WebSocket.Server(ws);
ws.web.on('connection', function(wire){

View File

@ -14,8 +14,9 @@ function Dup(opt){
if(pass){ it.pass = true }
if(!dup.to){
dup.to = setTimeout(function(){
var now = time_is();
Type.obj.map(dup.s, function(it, id){
if(opt.age > (time_is() - it.was)){ return }
if(opt.age > (now - it.was)){ return }
Type.obj.del(dup.s, id);
});
dup.to = null;

View File

@ -103,6 +103,7 @@ var Graph = {};
return valid(v,k,n, at,env);
}
env.err = "Invalid value at '" + at.path.concat(k).join('.') + "'!";
if(Type.list.is(v)){ env.err += " Use `.set(item)` instead of an Array." }
}
function seen(env, at){
var arr = env.seen, i = arr.length, has;