@ztimson/utils 0.25.16 → 0.25.18

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
@@ -1644,6 +1644,9 @@ function fracToDec(frac) {
1644
1644
  split = split.pop().split("/");
1645
1645
  return whole + Number(split[0]) / Number(split[1]);
1646
1646
  }
1647
+ function escapeRegex(value) {
1648
+ return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
1649
+ }
1647
1650
  function fn(args, fn2, async = false) {
1648
1651
  const keys = Object.keys(args);
1649
1652
  return new Function(...keys, `return (${async ? "async " : ""}(${keys.join(",")}) => { ${fn2} })(${keys.join(",")})`)(...keys.map((k) => args[k]));
@@ -1652,8 +1655,11 @@ function gravatar(email, def = "mp") {
1652
1655
  if (!email) return "";
1653
1656
  return `https://www.gravatar.com/avatar/${md5(email)}?d=${def}`;
1654
1657
  }
1655
- function escapeRegex(value) {
1656
- return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
1658
+ function ipV6ToV4(ip) {
1659
+ if (!ip) return null;
1660
+ const ipv4 = ip.split(":").splice(-1)[0];
1661
+ if (ipv4 == "1") return "127.0.0.1";
1662
+ return ipv4;
1657
1663
  }
1658
1664
  function PE(str, ...args) {
1659
1665
  const combined = [];
@@ -1788,7 +1794,7 @@ class PathEvent {
1788
1794
  const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
1789
1795
  const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
1790
1796
  return !!parsedRequired.find((r) => !!parsedTarget.find(
1791
- (t) => (r.fullPath == "*" || t.fullPath == "*" || r.fullPath.startsWith(t.fullPath) || t.fullPath.startsWith(r.fullPath)) && (r.all || t.all || r.methods.intersection(t.methods).length)
1797
+ (t) => (r.fullPath == "*" || t.fullPath == "*" || r.fullPath.startsWith(t.fullPath)) && (r.all || t.all || r.methods.intersection(t.methods).length)
1792
1798
  ));
1793
1799
  }
1794
1800
  /**
@@ -2178,6 +2184,7 @@ export {
2178
2184
  includes,
2179
2185
  insertAt,
2180
2186
  instantInterval,
2187
+ ipV6ToV4,
2181
2188
  isEqual,
2182
2189
  kebabCase,
2183
2190
  logicTest,