revise/correct set

This commit is contained in:
Mark Nadal 2021-06-02 22:44:21 -07:00
parent 3318e4559a
commit 8b299a03e2
2 changed files with 7 additions and 6 deletions

9
gun.js
View File

@ -1212,15 +1212,16 @@
;USE(function(module){
var Gun = USE('./index');
Gun.chain.set = function(item, cb, opt){
var gun = this, soul, tmp;
var gun = this, root = gun.back(-1), soul, tmp;
cb = cb || function(){};
opt = opt || {}; opt.item = opt.item || item;
if(soul = ((item||'')._||'')['#']){ (item = {})[soul] = {'#': soul}; }
if(soul = ((item||'')._||'')['#']){ (item = {})['#'] = soul } // check if node, make link.
if('string' == typeof (tmp = Gun.valid(item))){ return gun.get(soul = tmp).put(item, cb, opt) } // check if link
if(!Gun.is(item)){
if(Object.plain(item)){
soul = soul || ((item||'')._||'')['#'] || gun.back('opt.uuid')(7); // this just key now, not a soul.
item = root.get(soul = gun.back('opt.uuid')()).put(item);
}
return gun.get(soul || gun.back('opt.uuid')(7)).put(item, cb, opt);
return gun.get(soul || root.back('opt.uuid')(7)).put(item, cb, opt);
}
gun.put(function(go){
item.get(function(soul, o, msg){ // TODO: BUG! We no longer have this option? & go error not handled?

View File

@ -421,7 +421,7 @@ describe('SEA', function(){
setTimeout(function(){
user.get('who').put(stub);
setTimeout(function(){
var tmp = ref._.has;
var tmp = ref._.has || ref._.soul;
user.get('who').get('all').get(tmp).put({boom: 'ah'});
setTimeout(function(){
user.get('who').get('all').map().once(function(data){
@ -441,7 +441,7 @@ describe('SEA', function(){
this.timeout(9000);
var gun = Gun();
var user = gun.user();
user.auth('xavier', 'password');
user.create('xavier2', 'password2');
gun.on('auth', function(){
user.get("testauthed").get("arumf").set({"this": "is", "an": {"obj2": "again2"}}, function(ack) {
var notsigned = [];