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;
}
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(){
val.call({as:opt}, msg, eve, tmp || 1);
}, opt.wait || 99);

View File

@ -9,10 +9,10 @@ fs = require('fs');
Gun.on('create', function(root){
this.to.next(root);
var opt = root.opt;
//if(true !== opt.localStorage){ return }
if(true !== opt.localStorage){ return }
if(false === opt.localStorage){ return }
if(process.env.RAD_ENV){ return }
if(process.env.AWS_S3_BUCKET){ return }
//if(process.env.RAD_ENV){ return }
//if(process.env.AWS_S3_BUCKET){ return }
opt.file = String(opt.file || 'data.json');
var graph = root.graph, acks = {}, count = 0, to;
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;
if(data){ as.ack(g.err, data) }
else if(!as.file){ return as.ack(g.err, u) }
if(!last || last === tmp){ return } // is this correct?
if(last > tmp && 0 > last.indexOf(tmp)){ return }
if(!last || last === tmp){ return as.ack(g.err, u) } // is this correct?
if(last > tmp && 0 > last.indexOf(tmp)){ return as.ack(g.err, u) }
r.read(tmp, as.ack, as.file);
}
r.list(g.lex);

View File

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

View File

@ -1,7 +1,7 @@
;(function(){
var Gun = require('../gun'), u;
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){
this.to.next(root);
if(root.once){ return }

View File

@ -6,9 +6,9 @@ Gun.on('create', function(root){
if(typeof window !== "undefined"){
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(false === opt.radisk){ return }
if(false === opt.radisk){ return }
var Radisk = (opt.window && opt.window.Radisk) || require('./radisk');
var Radix = Radisk.Radix;
@ -44,7 +44,7 @@ Gun.on('create', function(root){
Radix.map(val, each);
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){
tmp = val.lastIndexOf('>');

View File

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

View File

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