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){
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(field){
node = Gun.obj.put({_: node._}, field, node[field]);
@ -947,6 +948,7 @@
if(cat.graph){
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});
}
function ham(data, key){
@ -2198,6 +2200,7 @@
Attempted merge with alancnet's `off` support, we'll see if it works.
*/
if(opt !== false){
console.debug(1, 'map!');
ons[ons.length] = gun.on(map, {change: true, as: cat});
}
}
@ -2224,6 +2227,8 @@
var gun = this.gun, cat = this.cat, id = this.id;
if(cat.list[id+f]){ return }
// 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', [id+f, {gun: (cat.list[id+f] = gun.path(f)), get: f, put: v}]);
}

View File

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