@ztimson/utils 0.16.8 → 0.16.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
@@ -363,7 +363,7 @@ class E extends Promise {
363
363
  return this.from(super.finally(e));
364
364
  }
365
365
  }
366
- function It(r, t) {
366
+ function jt(r, t) {
367
367
  r instanceof Blob || (r = new Blob(ut(r)));
368
368
  const e = URL.createObjectURL(r);
369
369
  at(e, t), URL.revokeObjectURL(e);
@@ -372,7 +372,7 @@ function at(r, t) {
372
372
  const e = document.createElement("a");
373
373
  e.href = r, e.download = t || r.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
374
374
  }
375
- function jt(r = {}) {
375
+ function It(r = {}) {
376
376
  return new Promise((t) => {
377
377
  const e = document.createElement("input");
378
378
  e.type = "file", e.accept = r.accept || "*", e.style.display = "none", e.multiple = !!r.multiple, e.onblur = e.onchange = async () => {
@@ -380,12 +380,12 @@ function jt(r = {}) {
380
380
  }, document.body.appendChild(e), e.click();
381
381
  });
382
382
  }
383
- function Mt(r, t = /* @__PURE__ */ new Date()) {
383
+ function Dt(r, t = /* @__PURE__ */ new Date()) {
384
384
  (typeof t == "number" || typeof t == "string") && (t = new Date(t));
385
385
  const e = `${t.getFullYear()}-${(t.getMonth() + 1).toString().padStart(2, "0")}-${t.getDate().toString().padStart(2, "0")}_${t.getHours().toString().padStart(2, "0")}-${t.getMinutes().toString().padStart(2, "0")}-${t.getSeconds().toString().padStart(2, "0")}`;
386
386
  return r ? r.replace("{{TIMESTAMP}}", e) : e;
387
387
  }
388
- function Dt(r) {
388
+ function Mt(r) {
389
389
  return new E((t, e, n) => {
390
390
  const o = new XMLHttpRequest(), s = new FormData();
391
391
  r.files.forEach((i) => s.append("file", i)), o.withCredentials = !!r.withCredentials, o.upload.addEventListener("progress", (i) => i.lengthComputable ? n(i.loaded / i.total) : null), o.addEventListener("loadend", () => t(T(o.responseText))), o.addEventListener("error", () => e(T(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", r.url), Object.entries(r.headers || {}).forEach(([i, y]) => o.setRequestHeader(i, y)), o.send(s);
@@ -497,7 +497,7 @@ class z extends p {
497
497
  }
498
498
  }
499
499
  c(z, "code", 403);
500
- class J extends p {
500
+ class K extends p {
501
501
  constructor(t = "Not Found") {
502
502
  super(t);
503
503
  }
@@ -505,8 +505,8 @@ class J extends p {
505
505
  return t.constructor.code == this.code;
506
506
  }
507
507
  }
508
- c(J, "code", 404);
509
- class K extends p {
508
+ c(K, "code", 404);
509
+ class J extends p {
510
510
  constructor(t = "Method Not Allowed") {
511
511
  super(t);
512
512
  }
@@ -514,7 +514,7 @@ class K extends p {
514
514
  return t.constructor.code == this.code;
515
515
  }
516
516
  }
517
- c(K, "code", 405);
517
+ c(J, "code", 405);
518
518
  class Z extends p {
519
519
  constructor(t = "Not Acceptable") {
520
520
  super(t);
@@ -582,9 +582,9 @@ function kt(r, t) {
582
582
  case 403:
583
583
  return new z(t);
584
584
  case 404:
585
- return new J(t);
586
- case 405:
587
585
  return new K(t);
586
+ case 405:
587
+ return new J(t);
588
588
  case 406:
589
589
  return new Z(t);
590
590
  case 500:
@@ -645,14 +645,14 @@ const w = class w {
645
645
  for (let a of [...Object.values(w.interceptors), ...Object.values(this.interceptors)])
646
646
  await new Promise((O) => a(u, () => O()));
647
647
  const R = u.headers.get("Content-Length"), L = R ? parseInt(R, 10) : 0;
648
- let D = 0;
648
+ let M = 0;
649
649
  const N = (k = u.body) == null ? void 0 : k.getReader(), et = new ReadableStream({
650
650
  start(a) {
651
651
  function O() {
652
652
  N == null || N.read().then((B) => {
653
653
  if (B.done)
654
654
  return a.close();
655
- D += B.value.byteLength, y(D / L), a.enqueue(B.value), O();
655
+ M += B.value.byteLength, y(M / L), a.enqueue(B.value), O();
656
656
  }).catch((B) => a.error(B));
657
657
  }
658
658
  O();
@@ -671,7 +671,7 @@ c(w, "interceptors", {}), c(w, "headers", {});
671
671
  let P = w;
672
672
  function Ut(r) {
673
673
  const t = r.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
674
- return T(decodeURIComponent(window.atob(t).split("").map(function(e) {
674
+ return T(decodeURIComponent(atob(t).split("").map(function(e) {
675
675
  return "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2);
676
676
  }).join("")));
677
677
  }
@@ -773,7 +773,7 @@ function qt(r) {
773
773
  const e = t.length == 2 ? Number(t[0]) : 0;
774
774
  return t = t.pop().split("/"), e + Number(t[0]) / Number(t[1]);
775
775
  }
776
- const I = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", j = "0123456789", M = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", ht = I + j + M;
776
+ const j = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", I = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", ht = j + I + D;
777
777
  function Ft(r, t = 2) {
778
778
  if (r === 0)
779
779
  return "0 Bytes";
@@ -801,19 +801,19 @@ function zt(r, t = ht) {
801
801
  return t[e];
802
802
  }).join("");
803
803
  }
804
- function Jt(r, t = !1, e = !1, n = !1) {
804
+ function Kt(r, t = !1, e = !1, n = !1) {
805
805
  if (!t && !e && !n)
806
806
  throw new Error("Must enable at least one: letters, numbers, symbols");
807
807
  return Array(r).fill(null).map(() => {
808
808
  let o;
809
809
  do {
810
810
  const s = ~~(Math.random() * 3);
811
- t && s == 0 ? o = I[~~(Math.random() * I.length)] : e && s == 1 ? o = j[~~(Math.random() * j.length)] : n && s == 2 && (o = M[~~(Math.random() * M.length)]);
811
+ t && s == 0 ? o = j[~~(Math.random() * j.length)] : e && s == 1 ? o = I[~~(Math.random() * I.length)] : n && s == 2 && (o = D[~~(Math.random() * D.length)]);
812
812
  } while (!o);
813
813
  return o;
814
814
  }).join("");
815
815
  }
816
- function Kt(r, t) {
816
+ function Jt(r, t) {
817
817
  if (typeof t == "string" && (t = new RegExp(t, "g")), !t.global)
818
818
  throw new TypeError("Regular expression must be global.");
819
819
  let e = [], n;
@@ -927,9 +927,9 @@ export {
927
927
  bt as JSONSanitize,
928
928
  lt as LOG_LEVEL,
929
929
  q as Logger,
930
- K as MethodNotAllowedError,
930
+ J as MethodNotAllowedError,
931
931
  Z as NotAcceptableError,
932
- J as NotFoundError,
932
+ K as NotFoundError,
933
933
  X as NotImplementedError,
934
934
  W as PaymentRequiredError,
935
935
  E as PromiseProgress,
@@ -942,15 +942,14 @@ export {
942
942
  ot as clean,
943
943
  Tt as csv,
944
944
  Pt as dec2Frac,
945
- Ut as decodeJwt,
946
945
  xt as deepCopy,
947
946
  st as deepMerge,
948
947
  x as dotNotation,
949
- It as downloadFile,
948
+ jt as downloadFile,
950
949
  at as downloadUrl,
951
950
  Bt as encodeQuery,
952
951
  kt as errorFromCode,
953
- jt as fileBrowser,
952
+ It as fileBrowser,
954
953
  $t as findByProp,
955
954
  it as flattenArr,
956
955
  F as flattenObj,
@@ -963,23 +962,24 @@ export {
963
962
  G as includes,
964
963
  Yt as insertAt,
965
964
  b as isEqual,
965
+ Ut as jwtDecode,
966
966
  ut as makeArray,
967
967
  ct as makeUnique,
968
- Kt as matchAll,
968
+ Jt as matchAll,
969
969
  ft as md5,
970
970
  At as mixin,
971
971
  Ht as pad,
972
972
  Zt as parseUrl,
973
973
  Wt as randomHex,
974
974
  zt as randomString,
975
- Jt as randomStringBuilder,
975
+ Kt as randomStringBuilder,
976
976
  mt as sleep,
977
977
  _t as sleepUntil,
978
978
  Lt as sortByProp,
979
979
  te as timeUntil,
980
- Mt as timestampFilename,
980
+ Dt as timestampFilename,
981
981
  ee as tyoeKeys,
982
- Dt as uploadWithProgress,
982
+ Mt as uploadWithProgress,
983
983
  Vt as validateEmail
984
984
  };
985
985
  //# sourceMappingURL=index.mjs.map