fix 1 of @mmalmi 's found bug.

This commit is contained in:
Mark Nadal 2018-08-23 23:49:25 -07:00
parent 0cad0fb724
commit 9781877db8
8 changed files with 30 additions and 15 deletions

14
gun.js
View File

@ -967,7 +967,6 @@
at.on('in', at);
return;
}*/
//console.log("out!", at.get, get);
if(get['#'] || at.soul){
get['#'] = get['#'] || at.soul;
msg['#'] || (msg['#'] = text_rand(9));
@ -1107,13 +1106,12 @@
not(at, msg);
}
tmp = from.id? ((at.map || (at.map = {}))[from.id] = at.map[from.id] || {at: from}) : {};
//console.log("REL?", at.id, at.get, rel === tmp.link, tmp.pass || at.pass);
if(rel === tmp.link){
if(!(tmp.pass || at.pass)){
return;
}
}
if(at.pass){
if(at.pass){
Gun.obj.map(at.map, function(tmp){ tmp.pass = true })
obj_del(at, 'pass');
}
@ -1730,10 +1728,8 @@
gun.map().on(function(data, key, at, ev){
var next = (cb||noop).call(this, data, key, at, ev);
if(u === next){ return }
if(data === next || Gun.is(next)){
chain._.on('in', next._);
return;
}
if(data === next){ return chain._.on('in', at) }
if(Gun.is(next)){ return chain._.on('in', next._) }
chain._.on('in', {get: key, put: next});
});
return chain;
@ -2024,11 +2020,7 @@
var wire = peer.wire;
try{
if(wire.send){
if(wire.readyState === wire.OPEN){
wire.send(raw);
} else {
(peer.queue = peer.queue || []).push(raw);
}
} else
if(peer.say){
peer.say(raw);

View File

@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.9.9998",
"version": "0.9.9999",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js",
"browser": "gun.min.js",

5
sea.js
View File

@ -1067,9 +1067,8 @@
var Gun = SEA.Gun;
var then = USE('./then');
function User(){
this._ = {$: this}
Gun.call()
function User(root){
this._ = {$: this};
}
User.prototype = (function(){ function F(){}; F.prototype = Gun.chain; return new F() }()) // Object.create polyfill
User.prototype.constructor = User;

View File

@ -3366,6 +3366,30 @@ describe('Gun', function(){
list.set({name: 'dave', age: 25});
});
it('once map function once', function(done){
var gun = Gun(), s = 'o/mf/o', u;
var app = gun.get(s);
var list = app.get('list');
var check = {};
gun.get('user').get('alice').put({name:'Alice', email:'alice@example.com'})
gun.get('user').get('bob').put({name:'Bob', email:'bob@example.com'})
gun.get('user').get('carl').put({name:'Carl', email:'carl@example.com'})
gun.get('user').once().map(v => {
//console.log('this gets called', v);
return v
}).once((v, k) => {
//console.log('this is never called', k, v);
check[k] = (check[k] || 0) + 1;
if(1 === check.alice && 1 === check.bob && 1 === check.carl){
if(done.c){return}done.c=1;
done();
}
});
});
it('val and then map', function(done){
var gun = Gun(), s = 'val/then/map', u;
var list = gun.get(s);