Skip to content

Commit

Permalink
Loading fix (#1356)
Browse files Browse the repository at this point in the history
* does this load better

* check window.Gun too in rfs
  • Loading branch information
bmatusiak authored Feb 5, 2024
1 parent 3070627 commit e584906
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
18 changes: 8 additions & 10 deletions lib/radisk.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,17 +590,15 @@
}
}());

if(typeof window !== "undefined"){
var Gun = window.Gun;
var Radix = window.Radix;
window.Radisk = Radisk;
} else {
var Gun = require('../gun');
var Radix = require('./radix');
//var Radix = require('./radix2'); Radisk = require('./radisk2');
try{ module.exports = Radisk }catch(e){}
}
var Gun = (typeof window !== "undefined" && window.Gun)? window.Gun : require('../gun');
var Radix = (typeof window !== "undefined" && window.Radix)? window.Radix : require('./radix');

Radisk.Radix = Radix;
((name, exports) => {
try { module.exports = exports } catch (e) { }
if (typeof window !== "undefined") {
window[name] = window[name]||exports;
}
})("Radisk", Radisk);

}());
11 changes: 6 additions & 5 deletions lib/radix.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@
} catch (e) { console.error(e); }
};

if(typeof window !== "undefined"){
window.Radix = Radix;
} else {
try{ module.exports = Radix }catch(e){}
}
(function(name, exports){
if(typeof window !== "undefined"){
window[name] = window[name]||exports;
}
try{ module.exports = exports }catch(e){}
})("Radix",Radix);
var each = Radix.object = function(o, f, r){
for(var k in o){
if(!o.hasOwnProperty(k)){ continue }
Expand Down
4 changes: 2 additions & 2 deletions lib/rfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ function Store(opt){
return store;
}

var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
var Gun = (typeof window !== "undefined" && window.Gun) ? window.Gun : require('../gun');
Gun.on('create', function(root){
this.to.next(root);
var opt = root.opt;
if(opt.rfs === false){ return }
opt.store = opt.store || (!Gun.window && Store(opt));
opt.store = opt.store || (!Gun.window || opt.rfs === true && Store(opt));
});

module.exports = Store;

0 comments on commit e584906

Please sign in to comment.