@ztimson/utils 0.26.7 → 0.26.9

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
@@ -1727,6 +1727,10 @@ function ipV6ToV4(ip) {
1727
1727
  if (ipv4 == "1") return "127.0.0.1";
1728
1728
  return ipv4;
1729
1729
  }
1730
+ function reservedIp(ip) {
1731
+ if (ip == "localhost") return true;
1732
+ return /\b(10\.(?:[0-9]{1,3}\.){2}[0-9]{1,3})\b|\b(172\.(?:1[6-9]|2[0-9]|3[0-1])\.(?:[0-9]{1,3}\.)[0-9]{1,3})\b|\b(192\.168\.(?:[0-9]{1,3}\.)[0-9]{1,3})\b/.test(ip);
1733
+ }
1730
1734
  function PE(str, ...args) {
1731
1735
  const combined = [];
1732
1736
  for (let i = 0; i < str.length || i < args.length; i++) {
@@ -2043,6 +2047,10 @@ function logicTest(target, condition) {
2043
2047
  return a == b;
2044
2048
  case "!=":
2045
2049
  return a != b;
2050
+ case "+":
2051
+ return a.includes(b);
2052
+ case "-":
2053
+ return !a.includes(b);
2046
2054
  case ">":
2047
2055
  return a > b;
2048
2056
  case ">=":
@@ -2059,7 +2067,7 @@ function logicTest(target, condition) {
2059
2067
  return -1 != or.findIndex((p) => {
2060
2068
  const and = p.split("&&").map((p2) => p2.trim()).filter((p2) => !!p2);
2061
2069
  return and.filter((p2) => {
2062
- const prop = /(\S+)\s*(==?|!=|>=|>|<=|<)\s*(\S+)/g.exec(p2);
2070
+ const prop = /(\S+)\s*(==?|!=|\+|-|>=|>|<=|<)\s*(\S+)/g.exec(p2);
2063
2071
  if (prop) {
2064
2072
  const key = Object.keys(target).find((k) => k.toLowerCase() == prop[1].toLowerCase());
2065
2073
  return evalBoolean(dotNotation(target, key || prop[1]), prop[2], JSONAttemptParse(prop[3]));
@@ -2328,6 +2336,7 @@ export {
2328
2336
  randomHex,
2329
2337
  randomString,
2330
2338
  randomStringBuilder,
2339
+ reservedIp,
2331
2340
  search,
2332
2341
  sleep,
2333
2342
  sleepWhile,