@ztimson/utils 0.26.22 → 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.mjs CHANGED
@@ -1747,6 +1747,11 @@ function fracToDec(frac) {
1747
1747
  split = split.pop().split("/");
1748
1748
  return whole + Number(split[0]) / Number(split[1]);
1749
1749
  }
1750
+ function compareVersions(target, vs) {
1751
+ const [tMajor, tMinor, tPatch] = target.split(".").map((v) => +v.replace(/[^0-9]/g, ""));
1752
+ const [vMajor, vMinor, vPatch] = vs.split(".").map((v) => +v.replace(/[^0-9]/g, ""));
1753
+ return tMajor > vMajor || tMinor > vMinor || tPatch > vPatch ? 1 : tMajor < vMajor || tMinor < vMinor || tPatch < vPatch ? -1 : 0;
1754
+ }
1750
1755
  function escapeRegex(value) {
1751
1756
  return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
1752
1757
  }
@@ -2330,6 +2335,7 @@ export {
2330
2335
  camelCase,
2331
2336
  caseInsensitiveSort,
2332
2337
  clean,
2338
+ compareVersions,
2333
2339
  contrast,
2334
2340
  createJwt,
2335
2341
  dec2Frac,