@ztimson/utils 0.26.4 → 0.26.6

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.mjs CHANGED
@@ -438,7 +438,7 @@ class Cache {
438
438
  if (this.options.persistentStorage != null) {
439
439
  if (typeof this.options.persistentStorage == "string")
440
440
  this.options.persistentStorage = { storage: localStorage, key: this.options.persistentStorage };
441
- if (((_b = (_a = this.options.persistentStorage) == null ? void 0 : _a.storage) == null ? void 0 : _b.constructor.name) == "Database") {
441
+ if (((_b = (_a = this.options.persistentStorage) == null ? void 0 : _a.storage) == null ? void 0 : _b.database) != void 0) {
442
442
  (async () => {
443
443
  const persists = this.options.persistentStorage;
444
444
  const table = await persists.storage.createTable({ name: persists.key, key: this.key });
@@ -446,7 +446,7 @@ class Cache {
446
446
  Object.assign(this.store, rows.reduce((acc, row) => ({ ...acc, [this.getKey(row)]: row }), {}));
447
447
  done();
448
448
  })();
449
- } else if (((_d = (_c = this.options.persistentStorage) == null ? void 0 : _c.storage) == null ? void 0 : _d.constructor.name) == "Storage") {
449
+ } else if (((_d = (_c = this.options.persistentStorage) == null ? void 0 : _c.storage) == null ? void 0 : _d.getItem) != void 0) {
450
450
  const stored = this.options.persistentStorage.storage.getItem(this.options.persistentStorage.key);
451
451
  if (stored != null) try {
452
452
  Object.assign(this.store, JSON.parse(stored));
@@ -476,7 +476,7 @@ class Cache {
476
476
  var _a, _b;
477
477
  const persists = this.options.persistentStorage;
478
478
  if (!!(persists == null ? void 0 : persists.storage)) {
479
- if (((_a = persists.storage) == null ? void 0 : _a.constructor.name) == "Database") {
479
+ if (((_a = persists.storage) == null ? void 0 : _a.database) != void 0) {
480
480
  persists.storage.createTable({ name: persists.key, key: this.key }).then((table) => {
481
481
  if (key) {
482
482
  table.set(this.get(key), key);
@@ -485,7 +485,7 @@ class Cache {
485
485
  this.all().forEach((row) => table.add(row));
486
486
  }
487
487
  });
488
- } else if (((_b = persists.storage) == null ? void 0 : _b.constructor.name) == "Storage") {
488
+ } else if (((_b = persists.storage) == null ? void 0 : _b.setItem) != void 0) {
489
489
  persists.storage.setItem(persists.storage.key, JSONSanitize(this.all(true)));
490
490
  }
491
491
  }
@@ -1993,10 +1993,13 @@ class PathEventEmitter {
1993
1993
  this.listeners = this.listeners.filter((l) => l[1] != listener);
1994
1994
  }
1995
1995
  on(event, listener) {
1996
- makeArray(event).forEach((e) => this.listeners.push([
1997
- e instanceof PathEvent ? e : new PathEvent(`${this.prefix}/${e}`),
1998
- listener
1999
- ]));
1996
+ makeArray(event).forEach((e) => {
1997
+ if (typeof e == "string" && e[0] == "*" && this.prefix) e = e.slice(1);
1998
+ this.listeners.push([
1999
+ e instanceof PathEvent ? e : new PathEvent(`${this.prefix}/${e}`),
2000
+ listener
2001
+ ]);
2002
+ });
2000
2003
  return () => this.off(listener);
2001
2004
  }
2002
2005
  once(event, listener) {