@ztimson/utils 0.20.3 → 0.20.4

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
@@ -228,7 +228,7 @@ class Tt {
228
228
  * @return {T[]} Array of items
229
229
  */
230
230
  c(this, "values", this.all());
231
- if (this.key = t, this.options = e, e.storageKey && !e.storage && (e.storage = localStorage), e.storageKey && e.storage) {
231
+ if (this.key = t, this.options = e, e.storageKey && !e.storage && localStorage && (e.storage = localStorage), e.storageKey && e.storage) {
232
232
  const n = e.storage.getItem(e.storageKey);
233
233
  if (n)
234
234
  try {
@@ -453,7 +453,7 @@ class K {
453
453
  }
454
454
  }
455
455
  c(K, "listeners", {});
456
- class g extends Error {
456
+ class y extends Error {
457
457
  constructor(e, n) {
458
458
  super(e);
459
459
  c(this, "_code");
@@ -480,8 +480,8 @@ class g extends Error {
480
480
  return this.message || super.toString();
481
481
  }
482
482
  }
483
- c(g, "code", 500);
484
- class W extends g {
483
+ c(y, "code", 500);
484
+ class W extends y {
485
485
  constructor(t = "Bad Request") {
486
486
  super(t);
487
487
  }
@@ -490,7 +490,7 @@ class W extends g {
490
490
  }
491
491
  }
492
492
  c(W, "code", 400);
493
- class v extends g {
493
+ class v extends y {
494
494
  constructor(t = "Unauthorized") {
495
495
  super(t);
496
496
  }
@@ -499,7 +499,7 @@ class v extends g {
499
499
  }
500
500
  }
501
501
  c(v, "code", 401);
502
- class J extends g {
502
+ class J extends y {
503
503
  constructor(t = "Payment Required") {
504
504
  super(t);
505
505
  }
@@ -508,7 +508,7 @@ class J extends g {
508
508
  }
509
509
  }
510
510
  c(J, "code", 402);
511
- class z extends g {
511
+ class z extends y {
512
512
  constructor(t = "Forbidden") {
513
513
  super(t);
514
514
  }
@@ -517,7 +517,7 @@ class z extends g {
517
517
  }
518
518
  }
519
519
  c(z, "code", 403);
520
- class Z extends g {
520
+ class Z extends y {
521
521
  constructor(t = "Not Found") {
522
522
  super(t);
523
523
  }
@@ -526,7 +526,7 @@ class Z extends g {
526
526
  }
527
527
  }
528
528
  c(Z, "code", 404);
529
- class V extends g {
529
+ class V extends y {
530
530
  constructor(t = "Method Not Allowed") {
531
531
  super(t);
532
532
  }
@@ -535,7 +535,7 @@ class V extends g {
535
535
  }
536
536
  }
537
537
  c(V, "code", 405);
538
- class X extends g {
538
+ class X extends y {
539
539
  constructor(t = "Not Acceptable") {
540
540
  super(t);
541
541
  }
@@ -544,7 +544,7 @@ class X extends g {
544
544
  }
545
545
  }
546
546
  c(X, "code", 406);
547
- class Q extends g {
547
+ class Q extends y {
548
548
  constructor(t = "Internal Server Error") {
549
549
  super(t);
550
550
  }
@@ -553,7 +553,7 @@ class Q extends g {
553
553
  }
554
554
  }
555
555
  c(Q, "code", 500);
556
- class _ extends g {
556
+ class _ extends y {
557
557
  constructor(t = "Not Implemented") {
558
558
  super(t);
559
559
  }
@@ -562,7 +562,7 @@ class _ extends g {
562
562
  }
563
563
  }
564
564
  c(_, "code", 501);
565
- class tt extends g {
565
+ class tt extends y {
566
566
  constructor(t = "Bad Gateway") {
567
567
  super(t);
568
568
  }
@@ -571,7 +571,7 @@ class tt extends g {
571
571
  }
572
572
  }
573
573
  c(tt, "code", 502);
574
- class et extends g {
574
+ class et extends y {
575
575
  constructor(t = "Service Unavailable") {
576
576
  super(t);
577
577
  }
@@ -580,7 +580,7 @@ class et extends g {
580
580
  }
581
581
  }
582
582
  c(et, "code", 503);
583
- class rt extends g {
583
+ class rt extends y {
584
584
  constructor(t = "Gateway Timeout") {
585
585
  super(t);
586
586
  }
@@ -617,7 +617,7 @@ function Gt(r, t) {
617
617
  case 504:
618
618
  return new rt(t);
619
619
  default:
620
- return new g(t, r);
620
+ return new y(t, r);
621
621
  }
622
622
  }
623
623
  const E = class E {
@@ -848,19 +848,19 @@ function Xt(r) {
848
848
  return e;
849
849
  }
850
850
  function dt(r) {
851
- var t = pt(gt(wt(yt(r), 8 * r.length)));
851
+ var t = pt(yt(wt(gt(r), 8 * r.length)));
852
852
  return t.toLowerCase();
853
853
  }
854
854
  function pt(r) {
855
855
  for (var t, e = "0123456789ABCDEF", n = "", s = 0; s < r.length; s++) t = r.charCodeAt(s), n += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
856
856
  return n;
857
857
  }
858
- function yt(r) {
858
+ function gt(r) {
859
859
  for (var t = Array(r.length >> 2), e = 0; e < t.length; e++) t[e] = 0;
860
860
  for (e = 0; e < 8 * r.length; e += 8) t[e >> 5] |= (255 & r.charCodeAt(e / 8)) << e % 32;
861
861
  return t;
862
862
  }
863
- function gt(r) {
863
+ function yt(r) {
864
864
  for (var t = "", e = 0; e < 32 * r.length; e += 8) t += String.fromCharCode(r[e >> 5] >>> e % 32 & 255);
865
865
  return t;
866
866
  }
@@ -907,16 +907,16 @@ function ee(r, ...t) {
907
907
  const e = [];
908
908
  for (let n = 0; n < r.length || n < t.length; n++)
909
909
  r[n] && e.push(r[n]), t[n] && e.push(t[n]);
910
- return new y(e.join(""));
910
+ return new g(e.join(""));
911
911
  }
912
912
  function mt(r, ...t) {
913
913
  let e = [];
914
914
  for (let i = 0; i < r.length || i < t.length; i++)
915
915
  r[i] && e.push(r[i]), t[i] && e.push(t[i]);
916
916
  const [n, s] = e.join("").split(":");
917
- return y.toString(n, s == null ? void 0 : s.split(""));
917
+ return g.toString(n, s == null ? void 0 : s.split(""));
918
918
  }
919
- class y {
919
+ class g {
920
920
  constructor(t) {
921
921
  /** First directory in path */
922
922
  c(this, "module");
@@ -956,7 +956,7 @@ class y {
956
956
  */
957
957
  static combine(t) {
958
958
  let e = !1;
959
- const n = t.map((s) => new y(s)).toSorted((s, i) => {
959
+ const n = t.map((s) => new g(s)).toSorted((s, i) => {
960
960
  const o = s.fullPath.length, a = i.fullPath.length;
961
961
  return o < a ? 1 : o > a ? -1 : 0;
962
962
  }).reduce((s, i) => (i.none && (e = !0), s ? (e || (i.all && (s.all = !0), (i.all || i.create) && (s.create = !0), (i.all || i.read) && (s.read = !0), (i.all || i.update) && (s.update = !0), (i.all || i.delete) && (s.delete = !0), s.methods = [...s.methods, ...i.methods]), s) : i), null);
@@ -970,12 +970,12 @@ class y {
970
970
  * @return {boolean} Whether there is any overlap
971
971
  */
972
972
  static has(t, ...e) {
973
- const n = m(e).map((i) => new y(i)), s = m(t).map((i) => new y(i));
973
+ const n = m(e).map((i) => new g(i)), s = m(t).map((i) => new g(i));
974
974
  return !!n.find((i) => {
975
975
  if (!i.fullPath && i.all) return !0;
976
976
  const o = s.filter((u) => i.fullPath.startsWith(u.fullPath));
977
977
  if (!o.length) return !1;
978
- const a = y.combine(o);
978
+ const a = g.combine(o);
979
979
  return !a.none && (a.all || new S(a.methods).intersection(new S(i.methods)).length);
980
980
  });
981
981
  }
@@ -987,7 +987,7 @@ class y {
987
987
  * @return {boolean} Whether there is any overlap
988
988
  */
989
989
  static hasAll(t, ...e) {
990
- return e.filter((n) => y.has(t, n)).length == e.length;
990
+ return e.filter((n) => g.has(t, n)).length == e.length;
991
991
  }
992
992
  /**
993
993
  * Same as `has` but raises an error if there is no overlap
@@ -996,7 +996,7 @@ class y {
996
996
  * @param has Target must have at least one of these path
997
997
  */
998
998
  static hasFatal(t, ...e) {
999
- if (!y.has(t, ...e)) throw new Error(`Requires one of: ${m(e).join(", ")}`);
999
+ if (!g.has(t, ...e)) throw new Error(`Requires one of: ${m(e).join(", ")}`);
1000
1000
  }
1001
1001
  /**
1002
1002
  * Same as `hasAll` but raises an error if the target is missing any paths
@@ -1005,7 +1005,7 @@ class y {
1005
1005
  * @param has Target must have all these paths
1006
1006
  */
1007
1007
  static hasAllFatal(t, ...e) {
1008
- if (!y.hasAll(t, ...e)) throw new Error(`Requires all: ${m(e).join(", ")}`);
1008
+ if (!g.hasAll(t, ...e)) throw new Error(`Requires all: ${m(e).join(", ")}`);
1009
1009
  }
1010
1010
  /**
1011
1011
  * Create event string from its components
@@ -1024,7 +1024,7 @@ class y {
1024
1024
  * @return {string} String representation of Event
1025
1025
  */
1026
1026
  toString() {
1027
- return y.toString(this.fullPath, this.methods);
1027
+ return g.toString(this.fullPath, this.methods);
1028
1028
  }
1029
1029
  }
1030
1030
  class re {
@@ -1032,14 +1032,14 @@ class re {
1032
1032
  c(this, "listeners", []);
1033
1033
  }
1034
1034
  emit(t, ...e) {
1035
- const n = new y(t);
1036
- this.listeners.filter((s) => y.has(s[0], t)).forEach(async (s) => s[1](n, ...e));
1035
+ const n = new g(t);
1036
+ this.listeners.filter((s) => g.has(s[0], t)).forEach(async (s) => s[1](n, ...e));
1037
1037
  }
1038
1038
  off(t) {
1039
1039
  this.listeners = this.listeners.filter((e) => e[1] != t);
1040
1040
  }
1041
1041
  on(t, e) {
1042
- return m(t).forEach((n) => this.listeners.push([new y(n), e])), () => this.off(e);
1042
+ return m(t).forEach((n) => this.listeners.push([new g(n), e])), () => this.off(e);
1043
1043
  }
1044
1044
  once(t, e) {
1045
1045
  return new Promise((n) => {
@@ -1077,7 +1077,7 @@ export {
1077
1077
  qt as CliBackground,
1078
1078
  R as CliEffects,
1079
1079
  L as CliForeground,
1080
- g as CustomError,
1080
+ y as CustomError,
1081
1081
  z as ForbiddenError,
1082
1082
  rt as GatewayTimeoutError,
1083
1083
  F as Http,
@@ -1092,7 +1092,7 @@ export {
1092
1092
  _ as NotImplementedError,
1093
1093
  ee as PE,
1094
1094
  mt as PES,
1095
- y as PathEvent,
1095
+ g as PathEvent,
1096
1096
  re as PathEventEmitter,
1097
1097
  J as PaymentRequiredError,
1098
1098
  x as PromiseProgress,