Skip to content

Commit

Permalink
fix Lex lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
amark committed Apr 27, 2019
1 parent b78e73a commit a111e20
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
18 changes: 10 additions & 8 deletions gun.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
if(t.slice(0, (tmp||'').length) === tmp){ return true }
if(u !== o['*']){ return false }
if(u !== o['>'] && u !== o['<']){
return (t > o['>'] && t < o['<'])? true : false;
return (t >= o['>'] && t <= o['<'])? true : false;
}
if(u !== o['>'] && t > o['>']){ return true }
if(u !== o['<'] && t < o['<']){ return true }
if(u !== o['>'] && t >= o['>']){ return true }
if(u !== o['<'] && t <= o['<']){ return true }
return false;
}
Type.list = {is: function(l){ return (l instanceof Array) }}
Expand Down Expand Up @@ -958,7 +958,7 @@
if(tmp){ return }
msg.$ = back.$;
} else
if(obj_has(back.put, get)){
if(obj_has(back.put, get)){ // TODO: support #LEX !
put = (back.$.get(get)._);
if(!(tmp = put.ack)){ put.ack = -1 }
back.on('in', {
Expand Down Expand Up @@ -1178,14 +1178,16 @@
});
}
function ask(at, soul){
var tmp = (at.root.$.get(soul)._);
if(at.ack){
tmp.on('out', {get: {'#': soul}});
var tmp = (at.root.$.get(soul)._), lex = at.lex;
if(at.ack || lex){
(lex = lex||{})['#'] = soul;
tmp.on('out', {get: lex});
if(!at.ask){ return } // TODO: PERFORMANCE? More elegant way?
}
tmp = at.ask; Gun.obj.del(at, 'ask');
obj_map(tmp || at.next, function(neat, key){
neat.on('out', {get: {'#': soul, '.': key}});
var lex = neat.lex || {}; lex['#'] = soul; lex['.'] = lex['.'] || key;
neat.on('out', {get: lex});
});
Gun.obj.del(at, 'ask'); // TODO: PERFORMANCE? More elegant way?
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.2019.427",
"version": "0.2019.428",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js",
"browser": "gun.js",
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function Mesh(ctx){
}
(msg._ = function(){}).via = peer;
if((tmp = msg['><'])){
(msg._).to = Type.obj.map(tmp.split(','), function(k,i,m){m(k,true)});
(msg._).to = Type.obj.map(tmp.split(','), tomap);
}
if(msg.dam){
if(tmp = mesh.hear[msg.dam]){
Expand All @@ -72,6 +72,7 @@ function Mesh(ctx){
return;
}
}
var tomap = function(k,i,m){m(k,true)};

;(function(){
mesh.say = function(msg, peer, o){
Expand Down
12 changes: 7 additions & 5 deletions src/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function output(msg){
if(tmp){ return }
msg.$ = back.$;
} else
if(obj_has(back.put, get)){
if(obj_has(back.put, get)){ // TODO: support #LEX !
put = (back.$.get(get)._);
if(!(tmp = put.ack)){ put.ack = -1 }
back.on('in', {
Expand Down Expand Up @@ -257,14 +257,16 @@ function not(at, msg){
});
}
function ask(at, soul){
var tmp = (at.root.$.get(soul)._);
if(at.ack){
tmp.on('out', {get: {'#': soul}});
var tmp = (at.root.$.get(soul)._), lex = at.lex;
if(at.ack || lex){
(lex = lex||{})['#'] = soul;
tmp.on('out', {get: lex});
if(!at.ask){ return } // TODO: PERFORMANCE? More elegant way?
}
tmp = at.ask; Gun.obj.del(at, 'ask');
obj_map(tmp || at.next, function(neat, key){
neat.on('out', {get: {'#': soul, '.': key}});
var lex = neat.lex || {}; lex['#'] = soul; lex['.'] = lex['.'] || key;
neat.on('out', {get: lex});
});
Gun.obj.del(at, 'ask'); // TODO: PERFORMANCE? More elegant way?
}
Expand Down
6 changes: 3 additions & 3 deletions src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Type.text.match = function(t, o){ var tmp, u;
if(t.slice(0, (tmp||'').length) === tmp){ return true }
if(u !== o['*']){ return false }
if(u !== o['>'] && u !== o['<']){
return (t > o['>'] && t < o['<'])? true : false;
return (t >= o['>'] && t <= o['<'])? true : false;
}
if(u !== o['>'] && t > o['>']){ return true }
if(u !== o['<'] && t < o['<']){ return true }
if(u !== o['>'] && t >= o['>']){ return true }
if(u !== o['<'] && t <= o['<']){ return true }
return false;
}
Type.list = {is: function(l){ return (l instanceof Array) }}
Expand Down

0 comments on commit a111e20

Please sign in to comment.