Merge pull request #175 from amark/develop

Develop
This commit is contained in:
Mark Nadal 2016-02-26 23:46:49 -08:00
commit ed09e548fe
3 changed files with 10 additions and 8 deletions

4
gun.js
View File

@ -392,7 +392,9 @@
Gun.is.node.state.ify([vertex, change, node], field, val);
}
emit({soul: soul, field: field, value: val, state: state, change: change});
}, function(vertex, field, val){})(function(){
}, function(vertex, field, val, state){
Gun.on('deferred').emit(gun, {soul: soul, field: field, value: val, state: state, change: node});
})(function(){
emit({soul: soul, change: node});
if(opt.soul){ opt.soul(soul) }
if(!(ctx.count -= 1)){ ctx.cb() }

View File

@ -126,7 +126,7 @@
tran.get = function(req, cb){
var key = req.url.key
, reply = {headers: {'Content-Type': tran.json, rid: req.headers.id, id: gun.wsp.msg()}};
//console.log(req);
//Gun.log(req);
// NTS HACK! SHOULD BE ITS OWN ISOLATED MODULE! //
if(req && req.url && req.url.pathname && req.url.pathname.indexOf('gun.nts') >= 0){
return cb({headers: reply.headers, body: {time: Gun.time.is() }});
@ -138,13 +138,13 @@
cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : list || null ) })
});
}
console.log("GET!", req);
//Gun.log("GET!", req);
key = req.body;
console.log("tran.get", key);
//Gun.log("tran.get", key);
var opt = {key: false};
//gun.get(key, function(err, node){
(gun.__.opt.wire.get||function(key, cb){cb(null,null)})(key, function(err, node){
//console.log("tran.get", key, "<---", err, node);
//Gun.log("tran.get", key, "<---", err, node);
reply.headers.id = gun.wsp.msg();
if(err || !node){
if(opt.on && opt.on.off){ opt.on.off() }
@ -182,7 +182,7 @@
// This will give you much more fine-grain control over security, transactions, and what not.
var reply = {headers: {'Content-Type': tran.json, rid: req.headers.id, id: gun.wsp.msg()}};
if(!req.body){ return cb({headers: reply.headers, body: {err: "No body"}}) }
//console.log("\n\ntran.put ----------------->", req.body);
//Gun.log("\n\ntran.put ----------------->", req.body);
if(Gun.is.graph(req.body)){
if(req.err = Gun.union(gun, req.body, function(err, ctx){ // TODO: BUG? Probably should give me ctx.graph
if(err){ return cb({headers: reply.headers, body: {err: err || "Union failed."}}) }
@ -193,7 +193,7 @@
(gun.__.opt.wire.put || function(g,cb){cb("No save.")})(ctx.graph, function(err, ok){
if(err){ return cb({headers: reply.headers, body: {err: err || "Failed."}}) } // TODO: err should already be an error object?
cb({headers: reply.headers, body: {ok: ok || "Persisted."}});
//console.log("tran.put <------------------------", ok);
//Gun.log("tran.put <------------------------", ok);
});
}).err){ cb({headers: reply.headers, body: {err: req.err || "Union failed."}}) }
} else {

View File

@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.3.7",
"version": "0.3.8",
"description": "Graph engine",
"main": "index.js",
"scripts": {