Update gun.js

This commit is contained in:
Mark Nadal 2016-10-12 01:35:20 -07:00 committed by GitHub
parent 9355a36a54
commit 58753e0f9e

13
gun.js
View File

@ -1818,7 +1818,9 @@
if(typeof field === 'string'){
tmp = field.split(opt.split || '.');
if(1 === tmp.length){
return back.get(field, cb, opt);
gun = back.get(field, cb, opt);
gun._.opt = opt;
return gun;
}
field = tmp;
}
@ -1835,12 +1837,15 @@
} else {
gun = back.get(field[0], cb, opt);
}
gun._.opt = opt;
return gun;
}
if(!field && 0 != field){
return back;
}
return back.get(''+field, cb, opt);
gun = back.get(''+field, cb, opt);
gun._.opt = opt;
return gun;
}
;(function(){
@ -2031,7 +2036,7 @@
var store = root.localStorage || {setItem: noop, removeItem: noop, getItem: noop};
function put(at){ var err, id, opt, root = at.gun._.root;
(opt = at.opt || {}).prefix = opt.prefix || (at.gun.Back('opt')||{}).prefix || 'gun/';
(opt = at.opt || {}).prefix = opt.prefix || at.gun.Back('opt.prefix') || 'gun/';
Gun.graph.is(at.put, function(node, soul){
//try{store.setItem(opt.prefix + soul, Gun.text.ify(node));
try{store.setItem(opt.prefix + soul, Gun.text.ify(root._.graph[soul]||node));
@ -2043,7 +2048,7 @@
function get(at){
var gun = at.gun, lex = at.get, soul, data, opt, u;
//setTimeout(function(){
(opt = at.opt || {}).prefix = opt.prefix || (at.gun.Back('opt')||{}).prefix || 'gun/';
(opt = at.opt || {}).prefix = opt.prefix || at.gun.Back('opt.prefix') || 'gun/';
if(!lex || !(soul = lex[Gun._.soul])){ return }
data = Gun.obj.ify(store.getItem(opt.prefix + soul) || null);
if(!data){ return } // localStorage isn't trustworthy to say "not found".