@ztimson/utils 0.25.22 → 0.25.23

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
@@ -579,7 +579,20 @@ class Cache {
579
579
  save(key) {
580
580
  if (this.options.storage) {
581
581
  if (this.options.storage instanceof Table) {
582
- this.options.storage.put(key, this.store[key]);
582
+ if (key == null) {
583
+ const rows = this.entries();
584
+ rows.forEach(([k, v]) => {
585
+ var _a;
586
+ return (_a = this.options.storage) == null ? void 0 : _a.put(k, v);
587
+ });
588
+ this.options.storage.getAllKeys().then((keys) => {
589
+ rows.map(([k]) => k).filter((k) => !keys.includes(k)).forEach((k) => {
590
+ var _a;
591
+ return (_a = this.options.storage) == null ? void 0 : _a.delete(k);
592
+ });
593
+ });
594
+ } else if (this.store[key] === void 0) this.options.storage.delete(key);
595
+ else this.options.storage.put(key, this.store[key]);
583
596
  } else if (this.options.storageKey) {
584
597
  this.options.storage.setItem(this.options.storageKey, JSONSanitize(this.store));
585
598
  }
@@ -621,6 +634,7 @@ class Cache {
621
634
  clear() {
622
635
  this.complete = false;
623
636
  this.store = {};
637
+ this.save();
624
638
  return this;
625
639
  }
626
640
  /**