@ztimson/utils 0.26.3 → 0.26.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -442,7 +442,7 @@ ${opts.message || this.desc}`;
442
442
  if (this.options.persistentStorage != null) {
443
443
  if (typeof this.options.persistentStorage == "string")
444
444
  this.options.persistentStorage = { storage: localStorage, key: this.options.persistentStorage };
445
- if (((_b = (_a = this.options.persistentStorage) == null ? void 0 : _a.storage) == null ? void 0 : _b.constructor.name) == "Database") {
445
+ if (((_b = (_a = this.options.persistentStorage) == null ? void 0 : _a.storage) == null ? void 0 : _b.database) != void 0) {
446
446
  (async () => {
447
447
  const persists = this.options.persistentStorage;
448
448
  const table = await persists.storage.createTable({ name: persists.key, key: this.key });
@@ -450,7 +450,7 @@ ${opts.message || this.desc}`;
450
450
  Object.assign(this.store, rows.reduce((acc, row) => ({ ...acc, [this.getKey(row)]: row }), {}));
451
451
  done();
452
452
  })();
453
- } else if (((_d = (_c = this.options.persistentStorage) == null ? void 0 : _c.storage) == null ? void 0 : _d.constructor.name) == "Storage") {
453
+ } else if (((_d = (_c = this.options.persistentStorage) == null ? void 0 : _c.storage) == null ? void 0 : _d.getItem) != void 0) {
454
454
  const stored = this.options.persistentStorage.storage.getItem(this.options.persistentStorage.key);
455
455
  if (stored != null) try {
456
456
  Object.assign(this.store, JSON.parse(stored));
@@ -480,16 +480,16 @@ ${opts.message || this.desc}`;
480
480
  var _a, _b;
481
481
  const persists = this.options.persistentStorage;
482
482
  if (!!(persists == null ? void 0 : persists.storage)) {
483
- if (((_a = persists.storage) == null ? void 0 : _a.constructor.name) == "Database") {
483
+ if (((_a = persists.storage) == null ? void 0 : _a.database) != void 0) {
484
484
  persists.storage.createTable({ name: persists.key, key: this.key }).then((table) => {
485
485
  if (key) {
486
- table.set(key, this.get(key));
486
+ table.set(this.get(key), key);
487
487
  } else {
488
488
  table.clear();
489
489
  this.all().forEach((row) => table.add(row));
490
490
  }
491
491
  });
492
- } else if (((_b = persists.storage) == null ? void 0 : _b.constructor.name) == "Storage") {
492
+ } else if (((_b = persists.storage) == null ? void 0 : _b.setItem) != void 0) {
493
493
  persists.storage.setItem(persists.storage.key, JSONSanitize(this.all(true)));
494
494
  }
495
495
  }