merge again

This commit is contained in:
Mark Nadal 2016-11-15 14:40:27 -08:00
parent 6b054146c8
commit 914cce726b
2 changed files with 25 additions and 18 deletions

5
gun.js
View File

@ -926,6 +926,7 @@
} }
function get(at, cat){ function get(at, cat){
var soul = at.get[_soul], node = cat.graph[soul], field = at.get[_field]; var soul = at.get[_soul], node = cat.graph[soul], field = at.get[_field];
console.debug(2, 'GET', soul, node, field);
if(node && (!field || obj_has(node, field))){ if(node && (!field || obj_has(node, field))){
if(field){ if(field){
node = Gun.obj.put({_: node._}, field, node[field]); node = Gun.obj.put({_: node._}, field, node[field]);
@ -947,6 +948,7 @@
if(cat.graph){ if(cat.graph){
Gun.obj.map(at.put, ham, {at: at, cat: cat}); // all unions must happen first, sadly. Gun.obj.map(at.put, ham, {at: at, cat: cat}); // all unions must happen first, sadly.
} }
console.debug(3, 'INPUT', at);
Gun.obj.map(at.put, map, {at: at, cat: cat}); Gun.obj.map(at.put, map, {at: at, cat: cat});
} }
function ham(data, key){ function ham(data, key){
@ -2198,6 +2200,7 @@
Attempted merge with alancnet's `off` support, we'll see if it works. Attempted merge with alancnet's `off` support, we'll see if it works.
*/ */
if(opt !== false){ if(opt !== false){
console.debug(1, 'map!');
ons[ons.length] = gun.on(map, {change: true, as: cat}); ons[ons.length] = gun.on(map, {change: true, as: cat});
} }
} }
@ -2224,6 +2227,8 @@
var gun = this.gun, cat = this.cat, id = this.id; var gun = this.gun, cat = this.cat, id = this.id;
if(cat.list[id+f]){ return } if(cat.list[id+f]){ return }
// TODO: BUG! Ghosting! // TODO: BUG! Ghosting!
console.debug(5, 'EACH', f,v);
console.debug(4, 'EACH', f,v);
return cat.on('in', {gun: (cat.list[id+f] = gun.path(f)), get: f, put: v, via: this.at}); return cat.on('in', {gun: (cat.list[id+f] = gun.path(f)), get: f, put: v, via: this.at});
//return cat.on('in', [id+f, {gun: (cat.list[id+f] = gun.path(f)), get: f, put: v}]); //return cat.on('in', [id+f, {gun: (cat.list[id+f] = gun.path(f)), get: f, put: v}]);
} }

View File

@ -1731,6 +1731,7 @@ describe('Gun', function(){
} }
}, s)}); }, s)});
var check = {}; var check = {};
console.debug.i=1;
(window.FOO = gun.get('u/m/p/n/mutate/n/u').map().path('pet')).on(function(v,f){ (window.FOO = gun.get('u/m/p/n/mutate/n/u').map().path('pet')).on(function(v,f){
check[v.name] = f; check[v.name] = f;
console.log("************", f,v);return; console.log("************", f,v);return;
@ -1744,6 +1745,7 @@ describe('Gun', function(){
},100); },100);
} }
}); });
return;
//gun.get('u/m/p/n/m/n/u/soul').path('alice').path('pet').on(function(v){console.log("?????????????????????????????????????????", v)}) //gun.get('u/m/p/n/m/n/u/soul').path('alice').path('pet').on(function(v){console.log("?????????????????????????????????????????", v)})
setTimeout(function(){ setTimeout(function(){
var s = Gun.state.map();s.soul = 'alice/fuzz/soul'; var s = Gun.state.map();s.soul = 'alice/fuzz/soul';
@ -6755,19 +6757,19 @@ describe('Gun', function(){
var alice = gun.put({name: 'alice', birth: Math.random()}).key('person/alice'); var alice = gun.put({name: 'alice', birth: Math.random()}).key('person/alice');
var bob = gun.put({name: 'bob', birth: Math.random()}).key('person/bob'); var bob = gun.put({name: 'bob', birth: Math.random()}).key('person/bob');
var carl = gun.put({name: 'carl', birth: Math.random()}).key('person/carl'); var carl = gun.put({name: 'carl', birth: Math.random()}).key('person/carl');
var dave = gun.put({name: 'dave', birth: Math.random()}).key('person/dave'); var dave = gun.put({name: 'dave', birth: Math.random()}).key('person/dave');
// Test set with new object // Test set with new object
var alan = users.set({name: 'alan', birth: Math.random()}).key('person/alan'); var alan = users.set({name: 'alan', birth: Math.random()}).key('person/alan');
alan.val(function(alan) { alan.val(function(alan) {
// Test set with node // Test set with node
dave.path('friends').set(alan); dave.path('friends').set(alan);
}); });
users.set(alice); users.set(alice);
users.set(bob); users.set(bob);
users.set(carl); users.set(carl);
users.set(dave); users.set(dave);
alice.path('friends').set(bob).back.set(carl); alice.path('friends').set(bob).back.set(carl);
bob.path('friends').set(alice); bob.path('friends').set(alice);
@ -6775,8 +6777,8 @@ describe('Gun', function(){
var team = gun.get('team/lions').put({name: "Lions"}); var team = gun.get('team/lions').put({name: "Lions"});
team.path('members').set(alice); team.path('members').set(alice);
team.path('members').set(bob); team.path('members').set(bob);
team.path('members').set(alan); // Test set with set team.path('members').set(alan); // Test set with set
alice.path('team').put(team); alice.path('team').put(team);
bob.path('team').put(team); bob.path('team').put(team);
@ -6788,14 +6790,14 @@ describe('Gun', function(){
} else } else
if('bob' === member.name){ if('bob' === member.name){
done.bob = true; done.bob = true;
} else } else
if('alan' === member.name){ if('alan' === member.name){
done.alan = true; done.alan = true;
} else } else
{ {
expect(member).to.not.be.ok(); expect(member).to.not.be.ok();
} }
if(done.alice && done.bob && done.alan){ if(done.alice && done.bob && done.alan){
setTimeout(function(){ setTimeout(function(){
done(); done();
},10); },10);