@fireproof/core 0.7.2-dev.2 → 0.7.2-dev.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/database.js CHANGED
@@ -78,6 +78,7 @@ export class Database {
78
78
  * @instance
79
79
  */
80
80
  toJSON() {
81
+ // todo this prepareHeader ignores secondary storage, need both
81
82
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader(); // omg
82
83
  }
83
84
  toHeader() {
@@ -39076,10 +39076,6 @@ const defaultConfig$1 = {
39076
39076
  class Browser extends Base {
39077
39077
  constructor (name, config = {}) {
39078
39078
  super(name, Object.assign({}, defaultConfig$1, config));
39079
- this.isBrowser = false;
39080
- try {
39081
- this.isBrowser = window.localStorage && true;
39082
- } catch (e) {}
39083
39079
  }
39084
39080
 
39085
39081
  withDB = async dbWorkFun => {
@@ -39119,12 +39115,16 @@ class Browser extends Base {
39119
39115
  }
39120
39116
 
39121
39117
  loadHeader (branch = 'main') {
39122
- return this.isBrowser && localStorage.getItem(this.headerKey(branch))
39118
+ try {
39119
+ return localStorage.getItem(this.headerKey(branch))
39120
+ } catch (e) {}
39123
39121
  }
39124
39122
 
39125
39123
  async writeHeader (branch, header) {
39126
39124
  if (this.config.readonly) return
39127
- return this.isBrowser && localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
39125
+ try {
39126
+ return localStorage.setItem(this.headerKey(branch), this.prepareHeader(header))
39127
+ } catch (e) {}
39128
39128
  }
39129
39129
 
39130
39130
  headerKey (branch = 'main') {
@@ -41642,6 +41642,7 @@ class Database {
41642
41642
  * @instance
41643
41643
  */
41644
41644
  toJSON () {
41645
+ // todo this prepareHeader ignores secondary storage, need both
41645
41646
  return this.blocks.valet ? this.blocks.valet.primary.prepareHeader(this.toHeader(), false) : this.toHeader() // omg
41646
41647
  }
41647
41648