@ztimson/utils 0.24.4 → 0.24.5

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/aset.d.ts CHANGED
@@ -15,6 +15,10 @@ export declare class ASet<T> extends Array {
15
15
  * @param items
16
16
  */
17
17
  add(...items: T[]): this;
18
+ /**
19
+ * Remove all elements
20
+ */
21
+ clear(): this;
18
22
  /**
19
23
  * Delete elements from set
20
24
  * @param items Elements that will be deleted
package/dist/index.cjs CHANGED
@@ -302,6 +302,13 @@ ${opts.message || this.desc}`;
302
302
  items.filter((el) => !this.has(el)).forEach((el) => this.push(el));
303
303
  return this;
304
304
  }
305
+ /**
306
+ * Remove all elements
307
+ */
308
+ clear() {
309
+ this.splice(0, this.length);
310
+ return this;
311
+ }
305
312
  /**
306
313
  * Delete elements from set
307
314
  * @param items Elements that will be deleted
@@ -1457,7 +1464,7 @@ ${opts.message || this.desc}`;
1457
1464
  class PathError extends Error {
1458
1465
  }
1459
1466
  class PathEvent {
1460
- constructor(Event) {
1467
+ constructor(e) {
1461
1468
  /** First directory in path */
1462
1469
  __publicField(this, "module");
1463
1470
  /** Entire path, including the module & name */
@@ -1469,8 +1476,8 @@ ${opts.message || this.desc}`;
1469
1476
  /** List of methods */
1470
1477
  __publicField(this, "methods");
1471
1478
  var _a;
1472
- if (typeof Event == "object") return Object.assign(this, Event);
1473
- let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
1479
+ if (typeof e == "object") return Object.assign(this, e);
1480
+ let [p, scope, method] = e.replaceAll(/\/{2,}/g, "/").split(":");
1474
1481
  if (!method) method = scope || "*";
1475
1482
  if (p == "*" || !p && method == "*") {
1476
1483
  p = "";
@@ -1478,8 +1485,8 @@ ${opts.message || this.desc}`;
1478
1485
  }
1479
1486
  let temp = p.split("/").filter((p2) => !!p2);
1480
1487
  this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
1481
- this.fullPath = p;
1482
1488
  this.path = temp.join("/");
1489
+ this.fullPath = `${this.module}${this.module && this.path ? "/" : ""}${this.path}`;
1483
1490
  this.name = temp.pop() || "";
1484
1491
  this.methods = new ASet(method.split(""));
1485
1492
  }
@@ -1526,7 +1533,7 @@ ${opts.message || this.desc}`;
1526
1533
  v ? this.methods.delete("n").delete("*").add("d") : this.methods.delete("d");
1527
1534
  }
1528
1535
  /**
1529
- * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
1536
+ * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
1530
1537
  * combined until a "none" is reached
1531
1538
  *
1532
1539
  * @param {string | PathEvent} paths Events as strings or pre-parsed
@@ -1609,14 +1616,14 @@ ${opts.message || this.desc}`;
1609
1616
  if (!PathEvent.hasAll(target, ...has)) throw new PathError(`Requires all: ${makeArray(has).join(", ")}`);
1610
1617
  }
1611
1618
  /**
1612
- * Create event string from its components
1619
+ * Create event string from its components
1613
1620
  *
1614
1621
  * @param {string | string[]} path Event path
1615
1622
  * @param {Method} methods Event method
1616
1623
  * @return {string} String representation of Event
1617
1624
  */
1618
1625
  static toString(path, methods) {
1619
- let p = makeArray(path).filter((p2) => p2 != null).join("/");
1626
+ let p = makeArray(path).filter((p2) => !!p2).join("/");
1620
1627
  p = p == null ? void 0 : p.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
1621
1628
  if (methods == null ? void 0 : methods.length) p += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
1622
1629
  return p;