@ztimson/utils 0.21.1 → 0.21.2
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +36 -36
- package/dist/index.mjs.map +1 -1
- package/dist/path-events.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -453,7 +453,7 @@ class W {
|
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
c(W, "listeners", {});
|
|
456
|
-
class
|
|
456
|
+
class y extends Error {
|
|
457
457
|
constructor(e, n) {
|
|
458
458
|
super(e);
|
|
459
459
|
c(this, "_code");
|
|
@@ -480,8 +480,8 @@ class m extends Error {
|
|
|
480
480
|
return this.message || super.toString();
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
c(
|
|
484
|
-
class v extends
|
|
483
|
+
c(y, "code", 500);
|
|
484
|
+
class v extends y {
|
|
485
485
|
constructor(t = "Bad Request") {
|
|
486
486
|
super(t);
|
|
487
487
|
}
|
|
@@ -490,7 +490,7 @@ class v extends m {
|
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
c(v, "code", 400);
|
|
493
|
-
class J extends
|
|
493
|
+
class J extends y {
|
|
494
494
|
constructor(t = "Unauthorized") {
|
|
495
495
|
super(t);
|
|
496
496
|
}
|
|
@@ -499,7 +499,7 @@ class J extends m {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
c(J, "code", 401);
|
|
502
|
-
class z extends
|
|
502
|
+
class z extends y {
|
|
503
503
|
constructor(t = "Payment Required") {
|
|
504
504
|
super(t);
|
|
505
505
|
}
|
|
@@ -508,7 +508,7 @@ class z extends m {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
c(z, "code", 402);
|
|
511
|
-
class Z extends
|
|
511
|
+
class Z extends y {
|
|
512
512
|
constructor(t = "Forbidden") {
|
|
513
513
|
super(t);
|
|
514
514
|
}
|
|
@@ -517,7 +517,7 @@ class Z extends m {
|
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
c(Z, "code", 403);
|
|
520
|
-
class V extends
|
|
520
|
+
class V extends y {
|
|
521
521
|
constructor(t = "Not Found") {
|
|
522
522
|
super(t);
|
|
523
523
|
}
|
|
@@ -526,7 +526,7 @@ class V extends m {
|
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
c(V, "code", 404);
|
|
529
|
-
class X extends
|
|
529
|
+
class X extends y {
|
|
530
530
|
constructor(t = "Method Not Allowed") {
|
|
531
531
|
super(t);
|
|
532
532
|
}
|
|
@@ -535,7 +535,7 @@ class X extends m {
|
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
c(X, "code", 405);
|
|
538
|
-
class Q extends
|
|
538
|
+
class Q extends y {
|
|
539
539
|
constructor(t = "Not Acceptable") {
|
|
540
540
|
super(t);
|
|
541
541
|
}
|
|
@@ -544,7 +544,7 @@ class Q extends m {
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
c(Q, "code", 406);
|
|
547
|
-
class _ extends
|
|
547
|
+
class _ extends y {
|
|
548
548
|
constructor(t = "Internal Server Error") {
|
|
549
549
|
super(t);
|
|
550
550
|
}
|
|
@@ -553,7 +553,7 @@ class _ extends m {
|
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
c(_, "code", 500);
|
|
556
|
-
class tt extends
|
|
556
|
+
class tt extends y {
|
|
557
557
|
constructor(t = "Not Implemented") {
|
|
558
558
|
super(t);
|
|
559
559
|
}
|
|
@@ -562,7 +562,7 @@ class tt extends m {
|
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
c(tt, "code", 501);
|
|
565
|
-
class et extends
|
|
565
|
+
class et extends y {
|
|
566
566
|
constructor(t = "Bad Gateway") {
|
|
567
567
|
super(t);
|
|
568
568
|
}
|
|
@@ -571,7 +571,7 @@ class et extends m {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
c(et, "code", 502);
|
|
574
|
-
class rt extends
|
|
574
|
+
class rt extends y {
|
|
575
575
|
constructor(t = "Service Unavailable") {
|
|
576
576
|
super(t);
|
|
577
577
|
}
|
|
@@ -580,7 +580,7 @@ class rt extends m {
|
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
c(rt, "code", 503);
|
|
583
|
-
class nt extends
|
|
583
|
+
class nt extends y {
|
|
584
584
|
constructor(t = "Gateway Timeout") {
|
|
585
585
|
super(t);
|
|
586
586
|
}
|
|
@@ -617,7 +617,7 @@ function Ut(r, t) {
|
|
|
617
617
|
case 504:
|
|
618
618
|
return new nt(t);
|
|
619
619
|
default:
|
|
620
|
-
return new
|
|
620
|
+
return new y(t, r);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
const E = class E {
|
|
@@ -733,7 +733,7 @@ const R = {
|
|
|
733
733
|
GREY: "\x1B[100m"
|
|
734
734
|
};
|
|
735
735
|
var dt = /* @__PURE__ */ ((r) => (r[r.ERROR = 0] = "ERROR", r[r.WARN = 1] = "WARN", r[r.INFO = 2] = "INFO", r[r.LOG = 3] = "LOG", r[r.DEBUG = 4] = "DEBUG", r))(dt || {});
|
|
736
|
-
const
|
|
736
|
+
const m = class m extends W {
|
|
737
737
|
constructor(t) {
|
|
738
738
|
super(), this.namespace = t;
|
|
739
739
|
}
|
|
@@ -742,33 +742,33 @@ const y = class y extends W {
|
|
|
742
742
|
return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${e.getHours().toString().padStart(2, "0")}:${e.getMinutes().toString().padStart(2, "0")}:${e.getSeconds().toString().padStart(2, "0")}.${e.getMilliseconds().toString().padEnd(3, "0")}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.map((s) => typeof s == "string" ? s : ut(s, 2)).join(" ")}`;
|
|
743
743
|
}
|
|
744
744
|
debug(...t) {
|
|
745
|
-
if (
|
|
745
|
+
if (m.LOG_LEVEL < 4) return;
|
|
746
746
|
const e = this.format(...t);
|
|
747
|
-
|
|
747
|
+
m.emit(4, e), console.debug(L.LIGHT_GREY + e + R.CLEAR);
|
|
748
748
|
}
|
|
749
749
|
log(...t) {
|
|
750
|
-
if (
|
|
750
|
+
if (m.LOG_LEVEL < 3) return;
|
|
751
751
|
const e = this.format(...t);
|
|
752
|
-
|
|
752
|
+
m.emit(3, e), console.log(R.CLEAR + e);
|
|
753
753
|
}
|
|
754
754
|
info(...t) {
|
|
755
|
-
if (
|
|
755
|
+
if (m.LOG_LEVEL < 2) return;
|
|
756
756
|
const e = this.format(...t);
|
|
757
|
-
|
|
757
|
+
m.emit(2, e), console.info(L.BLUE + e + R.CLEAR);
|
|
758
758
|
}
|
|
759
759
|
warn(...t) {
|
|
760
|
-
if (
|
|
760
|
+
if (m.LOG_LEVEL < 1) return;
|
|
761
761
|
const e = this.format(...t);
|
|
762
|
-
|
|
762
|
+
m.emit(1, e), console.warn(L.YELLOW + e + R.CLEAR);
|
|
763
763
|
}
|
|
764
764
|
error(...t) {
|
|
765
|
-
if (
|
|
765
|
+
if (m.LOG_LEVEL < 0) return;
|
|
766
766
|
const e = this.format(...t);
|
|
767
|
-
|
|
767
|
+
m.emit(0, e), console.error(L.RED + e + R.CLEAR);
|
|
768
768
|
}
|
|
769
769
|
};
|
|
770
|
-
c(
|
|
771
|
-
let Y =
|
|
770
|
+
c(m, "LOG_LEVEL", 4);
|
|
771
|
+
let Y = m;
|
|
772
772
|
function Yt(r) {
|
|
773
773
|
const t = (u, a) => a < 1e-7 ? u : t(a, ~~(u % a)), e = r.toString().length - 2;
|
|
774
774
|
let n = Math.pow(10, e), s = r * n;
|
|
@@ -842,14 +842,14 @@ function Qt(r) {
|
|
|
842
842
|
return e;
|
|
843
843
|
}
|
|
844
844
|
function gt(r) {
|
|
845
|
-
var t =
|
|
845
|
+
var t = yt(wt(Et(mt(r), 8 * r.length)));
|
|
846
846
|
return t.toLowerCase();
|
|
847
847
|
}
|
|
848
|
-
function
|
|
848
|
+
function yt(r) {
|
|
849
849
|
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);
|
|
850
850
|
return n;
|
|
851
851
|
}
|
|
852
|
-
function
|
|
852
|
+
function mt(r) {
|
|
853
853
|
for (var t = Array(r.length >> 2), e = 0; e < t.length; e++) t[e] = 0;
|
|
854
854
|
for (e = 0; e < 8 * r.length; e += 8) t[e >> 5] |= (255 & r.charCodeAt(e / 8)) << e % 32;
|
|
855
855
|
return t;
|
|
@@ -980,13 +980,13 @@ class g {
|
|
|
980
980
|
* @param {string | PathEvent} paths Events as strings or pre-parsed
|
|
981
981
|
* @return {PathEvent} Final combined permission
|
|
982
982
|
*/
|
|
983
|
-
static combine(t) {
|
|
983
|
+
static combine(...t) {
|
|
984
984
|
let e = !1;
|
|
985
985
|
const n = t.map((s) => new g(s)).toSorted((s, o) => {
|
|
986
986
|
const i = s.fullPath.length, u = o.fullPath.length;
|
|
987
987
|
return i < u ? 1 : i > u ? -1 : 0;
|
|
988
988
|
}).reduce((s, o) => (o.none && (e = !0), s ? (e || (o.all && (s.all = !0), (o.all || o.create) && (s.create = !0), (o.all || o.read) && (s.read = !0), (o.all || o.update) && (s.update = !0), (o.all || o.delete) && (s.delete = !0), s.methods = [...s.methods, ...o.methods]), s) : o), null);
|
|
989
|
-
return n.
|
|
989
|
+
return n.methods = new w(n.methods), n.raw = xt`${n.fullPath}:${n.methods}`, n;
|
|
990
990
|
}
|
|
991
991
|
/**
|
|
992
992
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
@@ -1001,7 +1001,7 @@ class g {
|
|
|
1001
1001
|
if (!o.fullPath && o.all) return !0;
|
|
1002
1002
|
const i = s.filter((a) => o.fullPath.startsWith(a.fullPath));
|
|
1003
1003
|
if (!i.length) return !1;
|
|
1004
|
-
const u = g.combine(i);
|
|
1004
|
+
const u = g.combine(...i);
|
|
1005
1005
|
return !u.none && (u.all || new w(u.methods).intersection(new w(o.methods)).length);
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
@@ -1042,7 +1042,7 @@ class g {
|
|
|
1042
1042
|
*/
|
|
1043
1043
|
static toString(t, e) {
|
|
1044
1044
|
let n = S(t).filter((s) => s != null).join("/");
|
|
1045
|
-
return e != null && e.length && (n += `:${S(e).map((s) => s.toLowerCase()).join("")}`), n
|
|
1045
|
+
return n = n == null ? void 0 : n.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, ""), e != null && e.length && (n += `:${S(e).map((s) => s.toLowerCase()).join("")}`), n;
|
|
1046
1046
|
}
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Create event string from its components
|
|
@@ -1103,7 +1103,7 @@ export {
|
|
|
1103
1103
|
Ft as CliBackground,
|
|
1104
1104
|
R as CliEffects,
|
|
1105
1105
|
L as CliForeground,
|
|
1106
|
-
|
|
1106
|
+
y as CustomError,
|
|
1107
1107
|
Z as ForbiddenError,
|
|
1108
1108
|
nt as GatewayTimeoutError,
|
|
1109
1109
|
F as Http,
|