update path for @mitra42

This commit is contained in:
Mark Nadal 2018-07-10 09:40:51 -07:00
parent d1dba14713
commit 314d5af7ef
2 changed files with 9 additions and 14 deletions

View File

@ -1,18 +1,15 @@
if(typeof window !== "undefined"){
var Gun = window.Gun;
} else {
var Gun = require('gun/gun');
var Gun = require('../gun');
}
Gun.chain.path = function(field, cb, opt){
Gun.chain.path = function(field, opt){
var back = this, gun = back, tmp;
opt = opt || {}; opt.path = true;
if(gun === gun.back(-1)){if(cb){cb({err: Gun.log("Can't do that on root instance.")})}return gun}
if(typeof field === 'string'){
tmp = field.split(opt.split || '.');
tmp = field.split(opt || '.');
if(1 === tmp.length){
gun = back.get(field, cb, opt);
gun._.opt = opt;
gun = back.get(field);
return gun;
}
field = tmp;
@ -22,19 +19,17 @@ Gun.chain.path = function(field, cb, opt){
gun = back;
var i = 0, l = field.length;
for(i; i < l; i++){
gun = gun.get(field[i], (i+1 === l)? cb : null, opt);
//gun = gun.get(field[i], (i+1 === l)? cb : null, opt);
gun = gun.get(field[i]);
}
//gun.back = back; // TODO: API change!
} else {
gun = back.get(field[0], cb, opt);
gun = back.get(field[0]);
}
gun._.opt = opt;
return gun;
}
if(!field && 0 != field){
return back;
}
gun = back.get(''+field, cb, opt);
gun._.opt = opt;
gun = back.get(''+field);
return gun;
}

View File

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