mirror of
https://github.com/amark/gun.git
synced 2025-06-07 22:56:42 +00:00
fix num_is & repeat maps
This commit is contained in:
parent
615a0f7fff
commit
e65c6cee57
21
gun.js
21
gun.js
@ -1060,15 +1060,12 @@
|
|||||||
} else {
|
} else {
|
||||||
if(obj_has(cat, 'put')){
|
if(obj_has(cat, 'put')){
|
||||||
//if(u !== cat.put){
|
//if(u !== cat.put){
|
||||||
//cat.gun !== at.gun && console.log("Potential Bug? Is the map not getting called?");// TODO: BUG! If the map is uncached, so the `out` propagates up to the parent, which has a map on it, this will emit to the last subscriber (which may not be an `input`), which if it isn't... won't propagate back down!
|
|
||||||
cat.on('in', cat);
|
cat.on('in', cat);
|
||||||
//cat.on('in').last.emit(cat);
|
//cat.on('in').last.emit(cat);
|
||||||
} else// TODO: BUG! Handle plural chains by iterating over them.
|
} else// TODO: BUG! Handle plural chains by iterating over them.
|
||||||
if(cat.map){ // TODO: map will exist but different than if something in it.
|
if(cat.map){
|
||||||
obj_map(cat.map, function(proxy){
|
obj_map(cat.map, function(proxy){
|
||||||
//console.log("CRASH3");
|
|
||||||
proxy.at.on('in', proxy.at);
|
proxy.at.on('in', proxy.at);
|
||||||
//cat.on('in').last.emit(coat);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(cat.ack){
|
if(cat.ack){
|
||||||
@ -1192,6 +1189,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
at = (gun._);
|
at = (gun._);
|
||||||
|
//if(data && data[_soul] && (tmp = Gun.val.rel.is(data)) && (tmp = (cat.root.get(tmp)._)) && obj_has(tmp, 'put')){
|
||||||
|
// data = tmp.put;
|
||||||
|
//}
|
||||||
if(at.field){
|
if(at.field){
|
||||||
if(!(data && data[_soul] && Gun.val.rel.is(data) === Gun.node.soul(at.put))){
|
if(!(data && data[_soul] && Gun.val.rel.is(data) === Gun.node.soul(at.put))){
|
||||||
at.put = data;
|
at.put = data;
|
||||||
@ -1280,7 +1280,7 @@
|
|||||||
if(num_is(key)){
|
if(num_is(key)){
|
||||||
return this.get(''+key, cb, as);
|
return this.get(''+key, cb, as);
|
||||||
} else {
|
} else {
|
||||||
(as = back.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
|
(as = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
|
||||||
if(cb){ cb.call(as, as._.err) }
|
if(cb){ cb.call(as, as._.err) }
|
||||||
return as;
|
return as;
|
||||||
}
|
}
|
||||||
@ -1326,6 +1326,7 @@
|
|||||||
ev.to.next(at);
|
ev.to.next(at);
|
||||||
}
|
}
|
||||||
var obj = Gun.obj, obj_has = obj.has, obj_to = Gun.obj.to;
|
var obj = Gun.obj, obj_has = obj.has, obj_to = Gun.obj.to;
|
||||||
|
var num_is = Gun.num.is;
|
||||||
var rel = Gun.val.rel, node_ = Gun.node._;
|
var rel = Gun.val.rel, node_ = Gun.node._;
|
||||||
var empty = {}, u;
|
var empty = {}, u;
|
||||||
})(require, './get');
|
})(require, './get');
|
||||||
@ -1902,18 +1903,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function val(at, ev, to){
|
function val(at, ev, to){
|
||||||
var opt = this.as, gun = at.gun, cat = gun._, data = cat.put || at.put;
|
var opt = this.as, cat = opt.cat, gun = at.gun, coat = gun._, data = coat.put || at.put;
|
||||||
if(u === data){
|
if(u === data){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(ev.wait){ clearTimeout(ev.wait) }
|
if(ev.wait){ clearTimeout(ev.wait) }
|
||||||
if(!to && (!(0 < cat.ack) || ((true === opt.async) && 0 !== opt.wait))){
|
if(!to && (!(0 < coat.ack) || ((true === opt.async) && 0 !== opt.wait))){
|
||||||
ev.wait = setTimeout(function(){
|
ev.wait = setTimeout(function(){
|
||||||
val.call({as:opt}, at, ev, ev.wait || 1)
|
val.call({as:opt}, at, ev, ev.wait || 1)
|
||||||
}, opt.wait || 99);
|
}, opt.wait || 99);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(cat.field || cat.soul){
|
||||||
if(ev.off()){ return } // if it is already off, don't call again!
|
if(ev.off()){ return } // if it is already off, don't call again!
|
||||||
|
} else {
|
||||||
|
if((opt.seen = opt.seen || {})[coat.id]){ return }
|
||||||
|
opt.seen[coat.id] = true;
|
||||||
|
}
|
||||||
opt.ok.call(at.gun || opt.gun, data, at.get);
|
opt.ok.call(at.gun || opt.gun, data, at.get);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1972,6 +1978,7 @@
|
|||||||
return chain;
|
return chain;
|
||||||
}
|
}
|
||||||
function map(at){
|
function map(at){
|
||||||
|
if(!at.put || Gun.val.is(at.put)){ return }
|
||||||
obj_map(at.put, each, {cat: this.as, gun: at.gun});
|
obj_map(at.put, each, {cat: this.as, gun: at.gun});
|
||||||
this.to.next(at);
|
this.to.next(at);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gun",
|
"name": "gun",
|
||||||
"version": "0.5.5",
|
"version": "0.5.6",
|
||||||
"description": "Graph engine",
|
"description": "Graph engine",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -3348,7 +3348,41 @@ describe('Gun', function(){
|
|||||||
});
|
});
|
||||||
},100);
|
},100);
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
|
it('multiple times partial', function(done){
|
||||||
|
var gun = Gun();
|
||||||
|
|
||||||
|
var s = Gun.state.map();s.soul = 'mult/times/part';
|
||||||
|
Gun.on('put', {gun: gun, put: Gun.graph.ify({
|
||||||
|
alias: {
|
||||||
|
mark: {
|
||||||
|
pub: {_:{'#':'pub'},
|
||||||
|
pub: 'asdf',
|
||||||
|
alias: 'mark',
|
||||||
|
born: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, s)});
|
||||||
|
|
||||||
|
var app = gun.get(s.soul);
|
||||||
|
|
||||||
|
app.path('alias').path('mark').map().val(function(alias){
|
||||||
|
done.alias = alias;
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
app.path('alias').map().map().path('born').on(function(data){
|
||||||
|
expect(data).to.be(1);
|
||||||
|
expect(done.alias.pub).to.be("asdf");
|
||||||
|
expect(done.alias.alias).to.be("mark");
|
||||||
|
expect(done.alias.born).to.be(1);
|
||||||
|
if(done.c){ return } done.c = 1;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
},300);
|
||||||
|
});return;
|
||||||
|
|
||||||
it.only('get any any none', function(done){
|
it.only('get any any none', function(done){
|
||||||
gun.get('full/none').get(function(at, ev){
|
gun.get('full/none').get(function(at, ev){
|
||||||
var err = at.err, data = at.put, field = at.get;
|
var err = at.err, data = at.put, field = at.get;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user