@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.cjs +15 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +15 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -583,7 +583,20 @@ ${opts.message || this.desc}`;
|
|
|
583
583
|
save(key) {
|
|
584
584
|
if (this.options.storage) {
|
|
585
585
|
if (this.options.storage instanceof Table) {
|
|
586
|
-
|
|
586
|
+
if (key == null) {
|
|
587
|
+
const rows = this.entries();
|
|
588
|
+
rows.forEach(([k, v]) => {
|
|
589
|
+
var _a;
|
|
590
|
+
return (_a = this.options.storage) == null ? void 0 : _a.put(k, v);
|
|
591
|
+
});
|
|
592
|
+
this.options.storage.getAllKeys().then((keys) => {
|
|
593
|
+
rows.map(([k]) => k).filter((k) => !keys.includes(k)).forEach((k) => {
|
|
594
|
+
var _a;
|
|
595
|
+
return (_a = this.options.storage) == null ? void 0 : _a.delete(k);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
} else if (this.store[key] === void 0) this.options.storage.delete(key);
|
|
599
|
+
else this.options.storage.put(key, this.store[key]);
|
|
587
600
|
} else if (this.options.storageKey) {
|
|
588
601
|
this.options.storage.setItem(this.options.storageKey, JSONSanitize(this.store));
|
|
589
602
|
}
|
|
@@ -625,6 +638,7 @@ ${opts.message || this.desc}`;
|
|
|
625
638
|
clear() {
|
|
626
639
|
this.complete = false;
|
|
627
640
|
this.store = {};
|
|
641
|
+
this.save();
|
|
628
642
|
return this;
|
|
629
643
|
}
|
|
630
644
|
/**
|