@ztimson/utils 0.20.8 → 0.20.9

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
@@ -7,7 +7,7 @@ function ct(n, t = !1) {
7
7
  (t && r === void 0 || !t && r == null) && delete n[e];
8
8
  }), n;
9
9
  }
10
- function Bt(n) {
10
+ function At(n) {
11
11
  return structuredClone(n);
12
12
  }
13
13
  function ut(n, ...t) {
@@ -26,7 +26,7 @@ function B(n, t, e) {
26
26
  return e !== void 0 && i == o.length - 1 ? r[s] = e : r[s];
27
27
  }, n);
28
28
  }
29
- function At(n) {
29
+ function Rt(n) {
30
30
  return Object.entries(n).map(
31
31
  ([t, e]) => encodeURIComponent(t) + "=" + encodeURIComponent(e)
32
32
  ).join("&");
@@ -40,7 +40,7 @@ function K(n, t, e = {}) {
40
40
  return e;
41
41
  }
42
42
  }
43
- function Rt(n) {
43
+ function Ot(n) {
44
44
  const t = new FormData();
45
45
  return Object.entries(n).forEach(([e, r]) => t.append(e, r)), t;
46
46
  }
@@ -54,7 +54,7 @@ function O(n, t) {
54
54
  const e = typeof n, r = typeof t;
55
55
  return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? !1 : Object.keys(n).every((i) => O(n[i], t[i]));
56
56
  }
57
- function Ot(n, t) {
57
+ function $t(n, t) {
58
58
  t.forEach((e) => {
59
59
  Object.getOwnPropertyNames(e.prototype).forEach((r) => {
60
60
  Object.defineProperty(
@@ -72,7 +72,7 @@ function I(n) {
72
72
  return n;
73
73
  }
74
74
  }
75
- function $t(n, t) {
75
+ function at(n, t) {
76
76
  let e = [];
77
77
  return JSON.stringify(n, (r, s) => {
78
78
  if (typeof s == "object" && s !== null) {
@@ -86,7 +86,7 @@ function Ct(n, t) {
86
86
  return n.indexOf(t) === -1 && n.push(t), n;
87
87
  }
88
88
  function Lt(n, t) {
89
- return lt([
89
+ return ft([
90
90
  ...n.filter((e) => !t.includes((r) => O(e, r))),
91
91
  ...t.filter((e) => !n.includes((r) => O(e, r)))
92
92
  ]);
@@ -100,8 +100,8 @@ function Nt(n) {
100
100
  function jt(n, t) {
101
101
  return (e) => O(B(e, n), t);
102
102
  }
103
- function at(n, t = []) {
104
- return n.forEach((e) => Array.isArray(e) ? at(e, t) : t.push(e)), t;
103
+ function lt(n, t = []) {
104
+ return n.forEach((e) => Array.isArray(e) ? lt(e, t) : t.push(e)), t;
105
105
  }
106
106
  function Tt(n, t = !1) {
107
107
  return function(e, r) {
@@ -109,7 +109,7 @@ function Tt(n, t = !1) {
109
109
  return typeof s == "number" && typeof i == "number" ? (t ? -1 : 1) * (s - i) : s > i ? t ? -1 : 1 : s < i ? t ? 1 : -1 : 0;
110
110
  };
111
111
  }
112
- function lt(n) {
112
+ function ft(n) {
113
113
  for (let t = n.length - 1; t >= 0; t--)
114
114
  n.slice(0, t).find((e) => O(e, n[t])) && n.splice(t, 1);
115
115
  return n;
@@ -386,9 +386,9 @@ class b extends Promise {
386
386
  function Mt(n, t) {
387
387
  n instanceof Blob || (n = new Blob(m(n)));
388
388
  const e = URL.createObjectURL(n);
389
- ft(e, t), URL.revokeObjectURL(e);
389
+ ht(e, t), URL.revokeObjectURL(e);
390
390
  }
391
- function ft(n, t) {
391
+ function ht(n, t) {
392
392
  const e = document.createElement("a");
393
393
  e.href = n, e.download = t || n.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
394
394
  }
@@ -732,7 +732,7 @@ const R = {
732
732
  WHITE: "\x1B[47m",
733
733
  GREY: "\x1B[100m"
734
734
  };
735
- var ht = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(ht || {});
735
+ var dt = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(dt || {});
736
736
  const w = class w extends W {
737
737
  constructor(t) {
738
738
  super(), this.namespace = t;
@@ -745,7 +745,7 @@ const w = class w extends W {
745
745
  }
746
746
  format(...t) {
747
747
  const e = /* @__PURE__ */ new Date();
748
- return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.join(" ")}`;
748
+ return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.map(at).join(" ")}`;
749
749
  }
750
750
  debug(...t) {
751
751
  if (w.LOG_LEVEL < 4) return;
@@ -788,7 +788,7 @@ function Ht(n) {
788
788
  const e = t.length == 2 ? Number(t[0]) : 0;
789
789
  return t = t.pop().split("/"), e + Number(t[0]) / Number(t[1]);
790
790
  }
791
- const D = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", M = "0123456789", k = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", dt = D + M + k;
791
+ const D = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", M = "0123456789", k = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", pt = D + M + k;
792
792
  function Kt(n, t = 2) {
793
793
  if (n === 0) return "0 Bytes";
794
794
  const e = 1024, r = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], s = Math.floor(Math.log(n) / Math.log(e));
@@ -808,7 +808,7 @@ function Jt(n, t, e = " ", r = !0) {
808
808
  function zt(n) {
809
809
  return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
810
810
  }
811
- function Zt(n, t = dt) {
811
+ function Zt(n, t = pt) {
812
812
  return Array(n).fill(null).map(() => {
813
813
  const e = ~~(Math.random() * t.length);
814
814
  return t[e];
@@ -847,24 +847,24 @@ function Qt(n) {
847
847
  }
848
848
  return e;
849
849
  }
850
- function pt(n) {
851
- var t = yt(wt(Et(gt(n), 8 * n.length)));
850
+ function yt(n) {
851
+ var t = gt(Et(mt(wt(n), 8 * n.length)));
852
852
  return t.toLowerCase();
853
853
  }
854
- function yt(n) {
854
+ function gt(n) {
855
855
  for (var t, e = "0123456789ABCDEF", r = "", s = 0; s < n.length; s++) t = n.charCodeAt(s), r += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
856
856
  return r;
857
857
  }
858
- function gt(n) {
858
+ function wt(n) {
859
859
  for (var t = Array(n.length >> 2), e = 0; e < t.length; e++) t[e] = 0;
860
860
  for (e = 0; e < 8 * n.length; e += 8) t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32;
861
861
  return t;
862
862
  }
863
- function wt(n) {
863
+ function Et(n) {
864
864
  for (var t = "", e = 0; e < 32 * n.length; e += 8) t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255);
865
865
  return t;
866
866
  }
867
- function Et(n, t) {
867
+ function mt(n, t) {
868
868
  n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t;
869
869
  for (var e = 1732584193, r = -271733879, s = -1732584194, i = 271733878, o = 0; o < n.length; o += 16) {
870
870
  var a = e, u = r, $ = s, j = i;
@@ -873,7 +873,7 @@ function Et(n, t) {
873
873
  return Array(e, r, s, i);
874
874
  }
875
875
  function N(n, t, e, r, s, i) {
876
- return x(mt(x(x(t, n), x(r, i)), s), e);
876
+ return x(St(x(x(t, n), x(r, i)), s), e);
877
877
  }
878
878
  function f(n, t, e, r, s, i, o) {
879
879
  return N(t & e | ~t & r, n, t, s, i, o);
@@ -891,14 +891,14 @@ function x(n, t) {
891
891
  var e = (65535 & n) + (65535 & t);
892
892
  return (n >> 16) + (t >> 16) + (e >> 16) << 16 | 65535 & e;
893
893
  }
894
- function mt(n, t) {
894
+ function St(n, t) {
895
895
  return n << t | n >>> 32 - t;
896
896
  }
897
897
  function _t(n) {
898
898
  return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
899
899
  }
900
900
  function te(n, t = "mp") {
901
- return n ? `https://www.gravatar.com/avatar/${pt(n)}?d=${t}` : "";
901
+ return n ? `https://www.gravatar.com/avatar/${yt(n)}?d=${t}` : "";
902
902
  }
903
903
  function ee(n) {
904
904
  return n.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
@@ -909,7 +909,7 @@ function ne(n, ...t) {
909
909
  n[r] && e.push(n[r]), t[r] && e.push(t[r]);
910
910
  return new y(e.join(""));
911
911
  }
912
- function St(n, ...t) {
912
+ function xt(n, ...t) {
913
913
  let e = [];
914
914
  for (let i = 0; i < n.length || i < t.length; i++)
915
915
  n[i] && e.push(n[i]), t[i] && e.push(t[i]);
@@ -962,7 +962,7 @@ class y {
962
962
  const o = s.fullPath.length, a = i.fullPath.length;
963
963
  return o < a ? 1 : o > a ? -1 : 0;
964
964
  }).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);
965
- return r.all && (r.methods = ["*"]), r.none && (r.methods = ["n"]), r.methods = new S(r.methods), r.raw = St`${r.fullPath}:${r.methods}`, r;
965
+ return r.all && (r.methods = ["*"]), r.none && (r.methods = ["n"]), r.methods = new S(r.methods), r.raw = xt`${r.fullPath}:${r.methods}`, r;
966
966
  }
967
967
  /**
968
968
  * Squash 2 sets of paths & return true if any overlap is found
@@ -1059,11 +1059,11 @@ function se(n) {
1059
1059
  let t = n.getHours(), e = "AM";
1060
1060
  return t >= 12 ? (t > 12 && (t -= 12), e = "PM") : t == 0 && (t = 12), `${n.getFullYear()}-${(n.getMonth() + 1).toString().padStart(2, "0")}-${n.getDate().toString().padStart(2, "0")}, ${t}:${n.getMinutes().toString().padStart(2, "0")} ${e}`;
1061
1061
  }
1062
- function xt(n) {
1062
+ function bt(n) {
1063
1063
  return new Promise((t) => setTimeout(t, n));
1064
1064
  }
1065
1065
  async function ie(n, t = 100) {
1066
- for (; await n(); ) await xt(t);
1066
+ for (; await n(); ) await bt(t);
1067
1067
  }
1068
1068
  function oe(n) {
1069
1069
  return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
@@ -1085,15 +1085,15 @@ export {
1085
1085
  F as Http,
1086
1086
  _ as InternalServerError,
1087
1087
  I as JSONAttemptParse,
1088
- $t as JSONSanitize,
1089
- ht as LOG_LEVEL,
1088
+ at as JSONSanitize,
1089
+ dt as LOG_LEVEL,
1090
1090
  Y as Logger,
1091
1091
  X as MethodNotAllowedError,
1092
1092
  Q as NotAcceptableError,
1093
1093
  V as NotFoundError,
1094
1094
  tt as NotImplementedError,
1095
1095
  ne as PE,
1096
- St as PES,
1096
+ xt as PES,
1097
1097
  H as PathError,
1098
1098
  y as PathEvent,
1099
1099
  re as PathEventEmitter,
@@ -1108,19 +1108,19 @@ export {
1108
1108
  ct as clean,
1109
1109
  Dt as csv,
1110
1110
  Yt as dec2Frac,
1111
- Bt as deepCopy,
1111
+ At as deepCopy,
1112
1112
  ut as deepMerge,
1113
1113
  B as dotNotation,
1114
1114
  Mt as downloadFile,
1115
- ft as downloadUrl,
1116
- At as encodeQuery,
1115
+ ht as downloadUrl,
1116
+ Rt as encodeQuery,
1117
1117
  Ut as errorFromCode,
1118
1118
  ee as escapeRegex,
1119
1119
  kt as fileBrowser,
1120
1120
  jt as findByProp,
1121
- at as flattenArr,
1121
+ lt as flattenArr,
1122
1122
  K as flattenObj,
1123
- Rt as formData,
1123
+ Ot as formData,
1124
1124
  Kt as formatBytes,
1125
1125
  se as formatDate,
1126
1126
  Wt as formatPhoneNumber,
@@ -1131,16 +1131,16 @@ export {
1131
1131
  O as isEqual,
1132
1132
  qt as jwtDecode,
1133
1133
  m as makeArray,
1134
- lt as makeUnique,
1134
+ ft as makeUnique,
1135
1135
  Xt as matchAll,
1136
- pt as md5,
1137
- Ot as mixin,
1136
+ yt as md5,
1137
+ $t as mixin,
1138
1138
  Jt as pad,
1139
1139
  Qt as parseUrl,
1140
1140
  zt as randomHex,
1141
1141
  Zt as randomString,
1142
1142
  Vt as randomStringBuilder,
1143
- xt as sleep,
1143
+ bt as sleep,
1144
1144
  ie as sleepWhile,
1145
1145
  Tt as sortByProp,
1146
1146
  oe as timeUntil,