@ztimson/utils 0.26.21 → 0.26.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 CHANGED
@@ -1114,9 +1114,9 @@ ${opts.message || this.desc}`;
1114
1114
  if (!this.includes(table.name)) {
1115
1115
  const newDb = new Database(this.database, [...this.tables, table], (this.version ?? 0) + 1);
1116
1116
  conn.close();
1117
- await newDb.connection;
1118
- Object.assign(this, newDb);
1117
+ this.connection = newDb.connection;
1119
1118
  await this.connection;
1119
+ Object.assign(this, newDb);
1120
1120
  }
1121
1121
  return this.table(table.name);
1122
1122
  });
@@ -1128,9 +1128,9 @@ ${opts.message || this.desc}`;
1128
1128
  const conn = await this.connection;
1129
1129
  const newDb = new Database(this.database, this.tables.filter((t) => t.name != table.name), (this.version ?? 0) + 1);
1130
1130
  conn.close();
1131
- await newDb.connection;
1132
- Object.assign(this, newDb);
1131
+ this.connection = newDb.connection;
1133
1132
  await this.connection;
1133
+ Object.assign(this, newDb);
1134
1134
  });
1135
1135
  }
1136
1136
  includes(name) {
@@ -1751,6 +1751,11 @@ ${opts.message || this.desc}`;
1751
1751
  split = split.pop().split("/");
1752
1752
  return whole + Number(split[0]) / Number(split[1]);
1753
1753
  }
1754
+ function compareVersions(target, vs) {
1755
+ const [tMajor, tMinor, tPatch] = target.split(".").map((v) => +v.replace(/[^0-9]/g, ""));
1756
+ const [vMajor, vMinor, vPatch] = vs.split(".").map((v) => +v.replace(/[^0-9]/g, ""));
1757
+ return tMajor > vMajor || tMinor > vMinor || tPatch > vPatch ? 1 : tMajor < vMajor || tMinor < vMinor || tPatch < vPatch ? -1 : 0;
1758
+ }
1754
1759
  function escapeRegex(value) {
1755
1760
  return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
1756
1761
  }
@@ -2333,6 +2338,7 @@ ${opts.message || this.desc}`;
2333
2338
  exports2.camelCase = camelCase;
2334
2339
  exports2.caseInsensitiveSort = caseInsensitiveSort;
2335
2340
  exports2.clean = clean;
2341
+ exports2.compareVersions = compareVersions;
2336
2342
  exports2.contrast = contrast;
2337
2343
  exports2.createJwt = createJwt;
2338
2344
  exports2.dec2Frac = dec2Frac;