@ztimson/utils 0.24.2 → 0.24.3

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
@@ -1443,7 +1443,7 @@ ${opts.message || this.desc}`;
1443
1443
  if (str[i]) combined.push(str[i]);
1444
1444
  if (args[i]) combined.push(args[i]);
1445
1445
  }
1446
- return new PathEvent(combined.join(""));
1446
+ return new PathEvent(combined.join("/"));
1447
1447
  }
1448
1448
  function PES(str, ...args) {
1449
1449
  let combined = [];
@@ -1502,28 +1502,28 @@ ${opts.message || this.desc}`;
1502
1502
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("c"));
1503
1503
  }
1504
1504
  set create(v) {
1505
- v ? this.methods.delete("n").add("c") : this.methods.delete("c");
1505
+ v ? this.methods.delete("n").delete("*").add("c") : this.methods.delete("c");
1506
1506
  }
1507
1507
  /** Read method specified */
1508
1508
  get read() {
1509
1509
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("r"));
1510
1510
  }
1511
1511
  set read(v) {
1512
- v ? this.methods.delete("n").add("r") : this.methods.delete("r");
1512
+ v ? this.methods.delete("n").delete("*").add("r") : this.methods.delete("r");
1513
1513
  }
1514
1514
  /** Update method specified */
1515
1515
  get update() {
1516
1516
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("u"));
1517
1517
  }
1518
1518
  set update(v) {
1519
- v ? this.methods.delete("n").add("u") : this.methods.delete("u");
1519
+ v ? this.methods.delete("n").delete("*").add("u") : this.methods.delete("u");
1520
1520
  }
1521
1521
  /** Delete method specified */
1522
1522
  get delete() {
1523
1523
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("d"));
1524
1524
  }
1525
1525
  set delete(v) {
1526
- v ? this.methods.delete("n").add("d") : this.methods.delete("d");
1526
+ v ? this.methods.delete("n").delete("*").add("d") : this.methods.delete("d");
1527
1527
  }
1528
1528
  /**
1529
1529
  * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
@@ -1681,11 +1681,11 @@ ${opts.message || this.desc}`;
1681
1681
  }
1682
1682
  }).length;
1683
1683
  } else {
1684
- return testCondition(search2, r);
1684
+ return logicTest(r, search2);
1685
1685
  }
1686
1686
  });
1687
1687
  }
1688
- function testCondition(condition, row) {
1688
+ function logicTest(target, condition) {
1689
1689
  const evalBoolean = (a, op, b) => {
1690
1690
  switch (op) {
1691
1691
  case "=":
@@ -1711,10 +1711,10 @@ ${opts.message || this.desc}`;
1711
1711
  return and.filter((p2) => {
1712
1712
  const prop = /(\S+)\s*(==?|!=|>=|>|<=|<)\s*(\S+)/g.exec(p2);
1713
1713
  if (prop) {
1714
- const key = Object.keys(row).find((k) => k.toLowerCase() == prop[1].toLowerCase());
1715
- return evalBoolean(dotNotation(row, key || prop[1]), prop[2], JSONAttemptParse(prop[3]));
1714
+ const key = Object.keys(target).find((k) => k.toLowerCase() == prop[1].toLowerCase());
1715
+ return evalBoolean(dotNotation(target, key || prop[1]), prop[2], JSONAttemptParse(prop[3]));
1716
1716
  }
1717
- const v = Object.values(row).map((v2) => typeof v2 == "object" && v2 != null ? JSON.stringify(v2) : v2).join("");
1717
+ const v = Object.values(target).map(JSONSerialize).join("");
1718
1718
  if (/[A-Z]/g.test(condition)) return v.includes(p2);
1719
1719
  return v.toLowerCase().includes(p2);
1720
1720
  }).length == and.length;
@@ -1794,6 +1794,7 @@ ${opts.message || this.desc}`;
1794
1794
  exports2.instantInterval = instantInterval;
1795
1795
  exports2.isEqual = isEqual;
1796
1796
  exports2.kebabCase = kebabCase;
1797
+ exports2.logicTest = logicTest;
1797
1798
  exports2.makeArray = makeArray;
1798
1799
  exports2.makeUnique = makeUnique;
1799
1800
  exports2.matchAll = matchAll;
@@ -1811,7 +1812,6 @@ ${opts.message || this.desc}`;
1811
1812
  exports2.snakeCase = snakeCase;
1812
1813
  exports2.sortByProp = sortByProp;
1813
1814
  exports2.strSplice = strSplice;
1814
- exports2.testCondition = testCondition;
1815
1815
  exports2.timeUntil = timeUntil;
1816
1816
  exports2.timestampFilename = timestampFilename;
1817
1817
  exports2.toCsv = toCsv;