This commit is contained in:
Mark Nadal 2017-10-30 07:23:36 -07:00
parent 4c8b679c4c
commit 4499562e34
5 changed files with 20 additions and 12 deletions

2
gun.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
var Gun = require('./root');
Gun.chain.back = function(n, opt){ var tmp;
n = n || 1;
if(-1 === n || Infinity === n){
return this._.root;
} else
@ -31,6 +32,7 @@ Gun.chain.back = function(n, opt){ var tmp;
&& !(yes = n(tmp, opt))){}
return yes;
}
return this;
}
var empty = {}, u;

View File

@ -55,6 +55,7 @@ function output(msg){
if(get['.']){
if(at.get){
msg = {get: {'.': at.get}, gun: at.gun};
(back.ask || (back.ask = {}))[at.get] = msg.gun; // TODO: PERFORMANCE? More elegant way?
return back.on('out', msg);
}
msg = {get: {}, gun: at.gun};
@ -64,6 +65,7 @@ function output(msg){
if(at.get){
msg.gun = at.gun;
get['.'] = at.get;
(back.ask || (back.ask = {}))[at.get] = msg.gun; // TODO: PERFORMANCE? More elegant way?
return back.on('out', msg);
}
}
@ -202,7 +204,7 @@ function not(at, msg){
if(!root.now || !root.now[at.id]){
if((u === msg.put && !msg['@']) && null === tmp){ return }
}
if(u === tmp && at.put !== u){ return } // TODO: Bug? Threw second condition in for a particular test, not sure if a counter example is tested though.
if(u === tmp && Gun.val.rel.is(at.put)){ return } // TODO: Bug? Threw second condition in for a particular test, not sure if a counter example is tested though.
obj_map(tmp, function(proxy){
if(!(proxy = proxy.at)){ return }
obj_del(proxy.echo, at.id);
@ -225,14 +227,15 @@ function ask(at, soul){
if(at.ack){
//tmp.ack = tmp.ack || -1;
tmp.on('out', {get: {'#': soul}});
return;
if(!at.ask){ return } // TODO: PERFORMANCE? More elegant way?
}
obj_map(at.next, function(gun, key){
obj_map(at.ask || at.next, function(gun, key){
//(tmp.gun.get(key)._).on('out', {get: {'#': soul, '.': key}});
//tmp.on('out', {get: {'#': soul, '.': key}});
(gun._).on('out', {get: {'#': soul, '.': key}});
//at.on('out', {get: {'#': soul, '.': key}});
});
Gun.obj.del(at, 'ask'); // TODO: PERFORMANCE? More elegant way?
}
function ack(msg, ev){
var as = this.as, get = as.get || empty, at = as.gun._;

View File

@ -9,16 +9,15 @@ Gun.chain.get = function(key, cb, as){
}
} else
if(key instanceof Function){
var gun = this, at = gun._, root = at.root._;
var gun = this, at = gun._, root = at.root._, tmp = root.now, ev;
as = cb || {};
as.use = key;
as.out = as.out || {};
as.out.get = as.out.get || {};
var tmp = at.on('in', use, as);
if(root.now){ ++root.now.$ }
(root.now || (root.now = {$:1}))[as.now = at.id] = tmp;
ev = at.on('in', use, as);
(root.now = {$:1})[as.now = at.id] = ev;
at.on('out', as.out);
if(!(--root.now.$)){ obj.del(root, 'now'); }
root.now = tmp;
return gun;
} else
if(num_is(key)){
@ -43,7 +42,7 @@ function cache(key, back){
if(cat.root === back){
at.soul = key;
} else
if(cat.soul || cat.field){ // TODO: Convert field to has!
if(cat.soul || cat.field || cat.has){ // TODO: Convert field to has!
at.field = at.has = key;
if(obj_has(cat.put, key)){
//at.put = cat.put[key];

View File

@ -108,15 +108,19 @@ Gun._ = { // some reserved key words, these are not the only ones.
};
if(this.ack){ msg['@'] = this.ack }
obj_map(node, each, this);
cat.on('node', msg);
}
function each(val, key){
var graph = this.graph, soul = this.soul, at = (this.at._), tmp;
graph[soul] = Gun.state.to(this.node, key, graph[soul]);
at.put = Gun.state.to(this.node, key, at.put);
}
function map(msg, soul){
function map(msg, soul){ var tmp;
if(!msg.gun){ return }
if((tmp = this.gun._).tag.node){
return tmp.on('node', function(msg){ this.off();
(msg.gun._).on('in', msg);
}).on.on('node', msg);
}
(msg.gun._).on('in', msg);
}