default to RAD!

This commit is contained in:
Mark Nadal 2018-07-22 00:11:50 -07:00
parent 6c72b1963e
commit 7e8d126e8c
8 changed files with 27 additions and 23 deletions

2
gun.js
View File

@ -1644,7 +1644,7 @@
data = tmp.put; data = tmp.put;
} }
if((tmp = eve.wait) && (tmp = tmp[at.id])){ clearTimeout(tmp) } if((tmp = eve.wait) && (tmp = tmp[at.id])){ clearTimeout(tmp) }
if(!to && (at.soul || at.link || (link && !(0 < link.ack)))){ if(!to && (u === data || at.soul || at.link || (link && !(0 < link.ack)))){
tmp = (eve.wait = {})[at.id] = setTimeout(function(){ tmp = (eve.wait = {})[at.id] = setTimeout(function(){
val.call({as:opt}, msg, eve, tmp || 1); val.call({as:opt}, msg, eve, tmp || 1);
}, opt.wait || 99); }, opt.wait || 99);

View File

@ -9,10 +9,10 @@ fs = require('fs');
Gun.on('create', function(root){ Gun.on('create', function(root){
this.to.next(root); this.to.next(root);
var opt = root.opt; var opt = root.opt;
//if(true !== opt.localStorage){ return } if(true !== opt.localStorage){ return }
if(false === opt.localStorage){ return } if(false === opt.localStorage){ return }
if(process.env.RAD_ENV){ return } //if(process.env.RAD_ENV){ return }
if(process.env.AWS_S3_BUCKET){ return } //if(process.env.AWS_S3_BUCKET){ return }
opt.file = String(opt.file || 'data.json'); opt.file = String(opt.file || 'data.json');
var graph = root.graph, acks = {}, count = 0, to; var graph = root.graph, acks = {}, count = 0, to;
var disk = Gun.obj.ify((fs.existsSync || require('path').existsSync)(opt.file)? var disk = Gun.obj.ify((fs.existsSync || require('path').existsSync)(opt.file)?

View File

@ -215,8 +215,8 @@
var tmp = as.key, rad = g.disk || noop, data = rad(tmp), last = rad.last; var tmp = as.key, rad = g.disk || noop, data = rad(tmp), last = rad.last;
if(data){ as.ack(g.err, data) } if(data){ as.ack(g.err, data) }
else if(!as.file){ return as.ack(g.err, u) } else if(!as.file){ return as.ack(g.err, u) }
if(!last || last === tmp){ return } // is this correct? if(!last || last === tmp){ return as.ack(g.err, u) } // is this correct?
if(last > tmp && 0 > last.indexOf(tmp)){ return } if(last > tmp && 0 > last.indexOf(tmp)){ return as.ack(g.err, u) }
r.read(tmp, as.ack, as.file); r.read(tmp, as.ack, as.file);
} }
r.list(g.lex); r.list(g.lex);

View File

@ -1,8 +1,9 @@
var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
function Store(opt){ function Store(opt){
opt = opt || {}; opt = opt || {};
opt.file = String(opt.file || 'radata'); opt.file = String(opt.file || 'radata');
var fs = require('fs'), u;
var Gun = require('../gun'), fs = require('fs'), u;
var store = function Store(){}; var store = function Store(){};
store.put = function(file, data, cb){ store.put = function(file, data, cb){
@ -63,11 +64,10 @@ function Store(opt){
function Mem(opt){ function Mem(opt){
opt = opt || {}; opt = opt || {};
opt.file = String(opt.file || 'radata'); opt.file = String(opt.file || 'radata');
var storage = {}; var storage = Mem.storage || (Mem.storage = {});
var Gun = require('../gun');
var store = function Store(){}, u; var store = function Store(){}, u;
store.put = function(file, data, cb){ store.put = function(file, data, cb){
setTimeout(function(){ setTimeout(function(){
storage[file] = data; storage[file] = data;
cb(null, 1); cb(null, 1);
}, 1); }, 1);
@ -86,4 +86,4 @@ function Mem(opt){
return store; return store;
} }
module.exports = Store; module.exports = Store;//Gun.TESTING? Mem : Store;

View File

@ -1,7 +1,7 @@
;(function(){ ;(function(){
var Gun = require('../gun'), u; var Gun = require('../gun'), u;
Gun.serve = require('./serve'); Gun.serve = require('./serve');
process.env.GUN_ENV = process.env.GUN_ENV || 'debug'; //process.env.GUN_ENV = process.env.GUN_ENV || 'debug';
Gun.on('opt', function(root){ Gun.on('opt', function(root){
this.to.next(root); this.to.next(root);
if(root.once){ return } if(root.once){ return }

View File

@ -6,9 +6,9 @@ Gun.on('create', function(root){
if(typeof window !== "undefined"){ if(typeof window !== "undefined"){
opt.window = window; opt.window = window;
} }
if(true !== opt.radisk && (!opt.window && !process.env.RAD_ENV && !process.env.AWS_S3_BUCKET) && false !== opt.localStorage){ return } //if(true !== opt.radisk && (!opt.window && !process.env.RAD_ENV && !process.env.AWS_S3_BUCKET) && false !== opt.localStorage){ return }
//if(true !== opt.radisk){ return } //if(true !== opt.radisk){ return }
//if(false === opt.radisk){ return } if(false === opt.radisk){ return }
var Radisk = (opt.window && opt.window.Radisk) || require('./radisk'); var Radisk = (opt.window && opt.window.Radisk) || require('./radisk');
var Radix = Radisk.Radix; var Radix = Radisk.Radix;
@ -44,7 +44,7 @@ Gun.on('create', function(root){
Radix.map(val, each); Radix.map(val, each);
if(!node){ each(val, key) } if(!node){ each(val, key) }
} }
root.on('in', {'@': id, '#': key, put: Gun.graph.node(node), err: err? err : u, rad: Radix}); root.on('in', {'@': id, put: Gun.graph.node(node), err: err? err : u, rad: Radix});
}); });
function each(val, key){ function each(val, key){
tmp = val.lastIndexOf('>'); tmp = val.lastIndexOf('>');

View File

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

View File

@ -11,13 +11,14 @@ describe('Gun', function(){
//root.Gun = root.Gun || require('../gun'); //root.Gun = root.Gun || require('../gun');
if(root.Gun){ if(root.Gun){
root.Gun = root.Gun; root.Gun = root.Gun;
root.Gun.TESTING = true;
} else { } else {
root.Gun = require('../gun'); root.Gun = require('../gun');
root.Gun.TESTING = true;
Gun.serve = require('../lib/serve'); Gun.serve = require('../lib/serve');
//require('./s3'); //require('../lib/file');
//require('./uws'); require('../lib/store');
//require('./wsp/server'); require('../lib/rfs');
require('../lib/file');
} }
}(this)); }(this));
//Gun.log.squelch = true; //Gun.log.squelch = true;
@ -2892,7 +2893,7 @@ describe('Gun', function(){
var gun = Gun().get('chat/asdf'); var gun = Gun().get('chat/asdf');
var check = {}, count = {}; var check = {}, count = {};
gun.map().val(function(v,f){ gun.map().once(function(v,f){
check[f] = v; check[f] = v;
count[f] = (count[f] || 0) + 1; count[f] = (count[f] || 0) + 1;
//console.log("**************", f, v); //console.log("**************", f, v);
@ -2993,6 +2994,7 @@ describe('Gun', function(){
it('get get get set root get put', function(done){ it('get get get set root get put', function(done){
var gun = Gun().get('app'); var gun = Gun().get('app');
//console.debug.i=1;console.log('---------------');
gun.get('alias').get('mark').set( gun.get('alias').get('mark').set(
gun.back(-1).get('pub').put({ gun.back(-1).get('pub').put({
alias: 'mark', alias: 'mark',
@ -3004,7 +3006,9 @@ describe('Gun', function(){
); );
//return; //return;
setTimeout(function(){ setTimeout(function(){
//console.debug.i=1;console.log('---------------');
gun.get(function(at){ gun.get(function(at){
//console.log("*", at.put);//return;
done.app = done.app || at.put.alias; done.app = done.app || at.put.alias;
}); });
gun.back(-1).get('pub').get(function(at){ gun.back(-1).get('pub').get(function(at){
@ -3016,7 +3020,7 @@ describe('Gun', function(){
done.alias = done.alias || at.put.mark; done.alias = done.alias || at.put.mark;
//!console.debug.i&&(console.debug.i=1)&&console.log("---------------------"); //!console.debug.i&&(console.debug.i=1)&&console.log("---------------------");
}).get('mark').on(function(data){ }).get('mark').on(function(data){
//console.log("************", at.put);//return; //console.log("************", data);//return;
clearTimeout(done.to); clearTimeout(done.to);
done.to = setTimeout(function(){ done.to = setTimeout(function(){
done.mark = done.mark || data.pub; done.mark = done.mark || data.pub;