@ztimson/utils 0.24.4 → 0.24.6

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
@@ -298,6 +298,13 @@ class ASet extends Array {
298
298
  items.filter((el) => !this.has(el)).forEach((el) => this.push(el));
299
299
  return this;
300
300
  }
301
+ /**
302
+ * Remove all elements
303
+ */
304
+ clear() {
305
+ this.splice(0, this.length);
306
+ return this;
307
+ }
301
308
  /**
302
309
  * Delete elements from set
303
310
  * @param items Elements that will be deleted
@@ -1453,7 +1460,7 @@ function PES(str, ...args) {
1453
1460
  class PathError extends Error {
1454
1461
  }
1455
1462
  class PathEvent {
1456
- constructor(Event) {
1463
+ constructor(e) {
1457
1464
  /** First directory in path */
1458
1465
  __publicField(this, "module");
1459
1466
  /** Entire path, including the module & name */
@@ -1465,8 +1472,8 @@ class PathEvent {
1465
1472
  /** List of methods */
1466
1473
  __publicField(this, "methods");
1467
1474
  var _a;
1468
- if (typeof Event == "object") return Object.assign(this, Event);
1469
- let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
1475
+ if (typeof e == "object") return Object.assign(this, e);
1476
+ let [p, scope, method] = e.replaceAll(/\/{2,}/g, "/").split(":");
1470
1477
  if (!method) method = scope || "*";
1471
1478
  if (p == "*" || !p && method == "*") {
1472
1479
  p = "";
@@ -1474,8 +1481,8 @@ class PathEvent {
1474
1481
  }
1475
1482
  let temp = p.split("/").filter((p2) => !!p2);
1476
1483
  this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
1477
- this.fullPath = p;
1478
1484
  this.path = temp.join("/");
1485
+ this.fullPath = `${this.module}${this.module && this.path ? "/" : ""}${this.path}`;
1479
1486
  this.name = temp.pop() || "";
1480
1487
  this.methods = new ASet(method.split(""));
1481
1488
  }
@@ -1522,7 +1529,7 @@ class PathEvent {
1522
1529
  v ? this.methods.delete("n").delete("*").add("d") : this.methods.delete("d");
1523
1530
  }
1524
1531
  /**
1525
- * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
1532
+ * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
1526
1533
  * combined until a "none" is reached
1527
1534
  *
1528
1535
  * @param {string | PathEvent} paths Events as strings or pre-parsed
@@ -1605,14 +1612,14 @@ class PathEvent {
1605
1612
  if (!PathEvent.hasAll(target, ...has)) throw new PathError(`Requires all: ${makeArray(has).join(", ")}`);
1606
1613
  }
1607
1614
  /**
1608
- * Create event string from its components
1615
+ * Create event string from its components
1609
1616
  *
1610
1617
  * @param {string | string[]} path Event path
1611
1618
  * @param {Method} methods Event method
1612
1619
  * @return {string} String representation of Event
1613
1620
  */
1614
1621
  static toString(path, methods) {
1615
- let p = makeArray(path).filter((p2) => p2 != null).join("/");
1622
+ let p = makeArray(path).filter((p2) => !!p2).join("/");
1616
1623
  p = p == null ? void 0 : p.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
1617
1624
  if (methods == null ? void 0 : methods.length) p += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
1618
1625
  return p;