This commit is contained in:
Mark Nadal 2019-01-04 20:38:26 -08:00
parent c3756193e9
commit 9f9b3e557c
8 changed files with 14 additions and 13 deletions

View File

@ -84,7 +84,7 @@ Gun.on('create', function(root){
var disk = Gun.obj.ify(store.getItem(opt.prefix)) || {}; var disk = Gun.obj.ify(store.getItem(opt.prefix)) || {};
var lS = function(){}, u; var lS = function(){}, u;
root.on('localStorage', disk); // NON-STANDARD EVENT! root.on('localStorage', disk); // NON-STANDARD EVENT!
root.on('put', function(at){ root.on('put', function(at){
this.to.next(at); this.to.next(at);
Gun.graph.is(at.put, null, map); Gun.graph.is(at.put, null, map);
@ -130,7 +130,7 @@ Gun.on('create', function(root){
acks = {}; acks = {};
if(data){ disk = data } if(data){ disk = data }
try{store.setItem(opt.prefix, JSON.stringify(disk)); try{store.setItem(opt.prefix, JSON.stringify(disk));
}catch(e){ }catch(e){
Gun.log(err = (e || "localStorage failure") + " Consider using GUN's IndexedDB plugin for RAD for more storage space, temporary example at https://github.com/amark/gun/blob/master/test/tmp/indexedDB.html ."); Gun.log(err = (e || "localStorage failure") + " Consider using GUN's IndexedDB plugin for RAD for more storage space, temporary example at https://github.com/amark/gun/blob/master/test/tmp/indexedDB.html .");
root.on('localStorage:error', {err: err, file: opt.prefix, flush: disk, retry: flush}); root.on('localStorage:error', {err: err, file: opt.prefix, flush: disk, retry: flush});
} }

View File

@ -57,8 +57,9 @@ function Mesh(ctx){
} }
return; return;
} }
ctx.on('in', msg); ctx.on('in', msg);
return; return;
} else } else
if('[' === tmp){ if('[' === tmp){

View File

@ -139,7 +139,7 @@ function input(msg){
//if(tmp[cat.id]){ return } //if(tmp[cat.id]){ return }
tmp.is = tmp.is || at.put; tmp.is = tmp.is || at.put;
tmp[cat.id] = at.put || true; tmp[cat.id] = at.put || true;
//if(root.stop){ //if(root.stop){
eve.to.next(msg) eve.to.next(msg)
//} //}
relate(cat, msg, at, rel); relate(cat, msg, at, rel);
@ -152,7 +152,7 @@ function relate(at, msg, from, rel){
var tmp = (at.root.$.get(rel)._); var tmp = (at.root.$.get(rel)._);
if(at.has){ if(at.has){
from = tmp; from = tmp;
} else } else
if(from.has){ if(from.has){
relate(from, msg, from, rel); relate(from, msg, from, rel);
} }
@ -204,7 +204,7 @@ function map(data, key){ // Map over only the changes on every update.
if(tmp = via.$){ if(tmp = via.$){
tmp = (chain = via.$.get(key))._; tmp = (chain = via.$.get(key))._;
if(u === tmp.put || !Gun.val.link.is(data)){ if(u === tmp.put || !Gun.val.link.is(data)){
tmp.put = data; tmp.put = data;
} }
} }
at.on('in', { at.on('in', {

View File

@ -88,7 +88,7 @@ function use(msg){
//root.stop && (root.stop.ID = root.stop.ID || Gun.text.random(2)); //root.stop && (root.stop.ID = root.stop.ID || Gun.text.random(2));
//if((tmp = root.stop) && (tmp = tmp[at.id] || (tmp[at.id] = {})) && tmp[cat.id]){ return } tmp && (tmp[cat.id] = true); //if((tmp = root.stop) && (tmp = tmp[at.id] || (tmp[at.id] = {})) && tmp[cat.id]){ return } tmp && (tmp[cat.id] = true);
if(eve.seen && at.id && eve.seen[at.id]){ return eve.to.next(msg) } if(eve.seen && at.id && eve.seen[at.id]){ return eve.to.next(msg) }
//if((tmp = root.stop)){ if(tmp[at.id]){ return } tmp[at.id] = msg.root; } // temporary fix till a better solution? //if((tmp = root.stop)){ if(tmp[at.id]){ return } tmp[at.id] = msg.root; } // temporary fix till a better solution?
if((tmp = data) && tmp[rel._] && (tmp = rel.is(tmp))){ if((tmp = data) && tmp[rel._] && (tmp = rel.is(tmp))){
tmp = ((msg.$$ = at.root.gun.get(tmp))._); tmp = ((msg.$$ = at.root.gun.get(tmp))._);

View File

@ -5,13 +5,13 @@ module.exports = function onto(tag, arg, as){
var u, tag = (this.tag || (this.tag = {}))[tag] || var u, tag = (this.tag || (this.tag = {}))[tag] ||
(this.tag[tag] = {tag: tag, to: onto._ = { (this.tag[tag] = {tag: tag, to: onto._ = {
next: function(arg){ var tmp; next: function(arg){ var tmp;
if((tmp = this.to)){ if((tmp = this.to)){
tmp.next(arg); tmp.next(arg);
}} }}
}}); }});
if(arg instanceof Function){ if(arg instanceof Function){
var be = { var be = {
off: onto.off || off: onto.off ||
(onto.off = function(){ (onto.off = function(){
if(this.next === onto._.next){ return !0 } if(this.next === onto._.next){ return !0 }
if(this === this.the.last){ if(this === this.the.last){

View File

@ -104,7 +104,7 @@ Gun.dup = require('./dup');
if(!at){ if(!at){
if(!(cat.opt||empty).super){ if(!(cat.opt||empty).super){
ctx.souls[soul] = false; ctx.souls[soul] = false;
return; return;
} }
at = (ctx.$.get(soul)._); at = (ctx.$.get(soul)._);
} }

View File

@ -26,10 +26,10 @@ State.lex = function(){ return State().toString(36).replace('.','') }
State.ify = function(n, k, s, v, soul){ // put a key's state on a node. State.ify = function(n, k, s, v, soul){ // put a key's state on a node.
if(!n || !n[N_]){ // reject if it is not node-like. if(!n || !n[N_]){ // reject if it is not node-like.
if(!soul){ // unless they passed a soul if(!soul){ // unless they passed a soul
return; return;
} }
n = Node.soul.ify(n, soul); // then make it so! n = Node.soul.ify(n, soul); // then make it so!
} }
var tmp = obj_as(n[N_], State._); // grab the states data. var tmp = obj_as(n[N_], State._); // grab the states data.
if(u !== k && k !== N_){ if(u !== k && k !== N_){
if(num_is(s)){ if(num_is(s)){

View File

@ -7,7 +7,7 @@ Val.is = function(v){ // Valid values are a subset of JSON: null, binary, number
if(v === Infinity){ return false } // we want this to be, but JSON does not support it, sad face. if(v === Infinity){ return false } // we want this to be, but JSON does not support it, sad face.
if(text_is(v) // by "text" we mean strings. if(text_is(v) // by "text" we mean strings.
|| bi_is(v) // by "binary" we mean boolean. || bi_is(v) // by "binary" we mean boolean.
|| num_is(v)){ // by "number" we mean integers or decimals. || num_is(v)){ // by "number" we mean integers or decimals.
return true; // simple values are valid. return true; // simple values are valid.
} }
return Val.rel.is(v) || false; // is the value a soul relation? Then it is valid and return it. If not, everything else remaining is an invalid data type. Custom extensions can be built on top of these primitives to support other types. return Val.rel.is(v) || false; // is the value a soul relation? Then it is valid and return it. If not, everything else remaining is an invalid data type. Custom extensions can be built on top of these primitives to support other types.