@ztimson/utils 0.26.2 → 0.26.4

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
@@ -479,7 +479,7 @@ class Cache {
479
479
  if (((_a = persists.storage) == null ? void 0 : _a.constructor.name) == "Database") {
480
480
  persists.storage.createTable({ name: persists.key, key: this.key }).then((table) => {
481
481
  if (key) {
482
- table.set(key, this.get(key));
482
+ table.set(this.get(key), key);
483
483
  } else {
484
484
  table.clear();
485
485
  this.all().forEach((row) => table.add(row));
@@ -1141,15 +1141,19 @@ class Table {
1141
1141
  getAllKeys() {
1142
1142
  return this.tx(this.name, (store) => store.getAllKeys(), true);
1143
1143
  }
1144
- put(key, value) {
1145
- return this.tx(this.name, (store) => store.put(value, key));
1144
+ put(value, key) {
1145
+ return this.tx(this.name, (store) => {
1146
+ if (store.keyPath) return store.put(value);
1147
+ return store.put(value, key);
1148
+ });
1146
1149
  }
1147
1150
  read(key) {
1148
1151
  return key ? this.get(key) : this.getAll();
1149
1152
  }
1150
1153
  set(value, key) {
1151
- if (!key && !value[this.key]) return this.add(value);
1152
- return this.put(key || value[this.key], value);
1154
+ if (key) value[this.key] = key;
1155
+ if (!value[this.key]) return this.add(value);
1156
+ return this.put(value);
1153
1157
  }
1154
1158
  }
1155
1159
  class PromiseProgress extends Promise {