@unicom-cloud/utils 0.1.1

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.
Files changed (69) hide show
  1. package/case-name/index.js +23 -0
  2. package/class-name/index.js +9 -0
  3. package/clipboard-copy/index.js +41 -0
  4. package/constant/address.js +5304 -0
  5. package/constant/chineseCharacters.js +4 -0
  6. package/constant/constellations.js +17 -0
  7. package/constant/domain.js +268 -0
  8. package/constant/identity.js +18 -0
  9. package/constant/index.js +6 -0
  10. package/constant/keyboardCode.js +105 -0
  11. package/constant/licensePlate.js +42 -0
  12. package/constant/name.js +666 -0
  13. package/constant/platform.js +20 -0
  14. package/constant/protocol.js +18 -0
  15. package/constant/ui.js +17 -0
  16. package/cookie/index.js +33 -0
  17. package/cookie/src/index.js +116 -0
  18. package/decimal/decimal.js +1070 -0
  19. package/decimal/index.js +5 -0
  20. package/event-emitter/index.js +57 -0
  21. package/file/fileToURL.js +26 -0
  22. package/file/index.js +6 -0
  23. package/file/saveAs.js +35 -0
  24. package/filesize/index.js +8 -0
  25. package/filesize/src/constants.js +71 -0
  26. package/filesize/src/filesize.js +88 -0
  27. package/index.js +47 -0
  28. package/invariant/index.js +21 -0
  29. package/is/index.js +137 -0
  30. package/math/index.js +34 -0
  31. package/md5/index.js +65 -0
  32. package/mock/MockWebSocket.js +117 -0
  33. package/mock/MockXMLHttpRequest.js +94 -0
  34. package/mock/index.js +8 -0
  35. package/normalize-wheel/ExecutionEnvironment.js +11 -0
  36. package/normalize-wheel/UserAgent_DEPRECATED.js +146 -0
  37. package/normalize-wheel/index.js +13 -0
  38. package/normalize-wheel/isEventSupported.js +33 -0
  39. package/nzh/cn.js +7 -0
  40. package/nzh/hk.js +7 -0
  41. package/nzh/index.js +4 -0
  42. package/nzh/nzh.js +22 -0
  43. package/nzh/src/autoGet.js +25 -0
  44. package/nzh/src/index.js +93 -0
  45. package/nzh/src/langs/cn_b.js +12 -0
  46. package/nzh/src/langs/cn_s.js +9 -0
  47. package/nzh/src/langs/hk_b.js +12 -0
  48. package/nzh/src/langs/hk_s.js +9 -0
  49. package/nzh/src/utils.js +71 -0
  50. package/objectKeysSort.js +7 -0
  51. package/package.json +1 -0
  52. package/random/address.js +32 -0
  53. package/random/constellation.js +8 -0
  54. package/random/image.js +20 -0
  55. package/random/index.js +63 -0
  56. package/random/licensePlate.js +12 -0
  57. package/random/name.js +25 -0
  58. package/random/number.js +15 -0
  59. package/random/text.js +117 -0
  60. package/random/time.js +8 -0
  61. package/random/web.js +37 -0
  62. package/screenfull/index.js +119 -0
  63. package/tree/index.js +87 -0
  64. package/turbo-stream/index.js +6 -0
  65. package/turbo-stream/src/decode.js +284 -0
  66. package/turbo-stream/src/encode.js +363 -0
  67. package/turbo-stream/src/shared.js +287 -0
  68. package/url-toolkit/index.js +8 -0
  69. package/url-toolkit/src/url-toolkit.js +74 -0
@@ -0,0 +1,33 @@
1
+ import * as p from "./src/index.js";
2
+ function A(e = "") {
3
+ if (Array.isArray(e))
4
+ return e;
5
+ if (typeof e != "string")
6
+ return [];
7
+ const h = [];
8
+ let t = 0, a, l, r, n, u;
9
+ function f() {
10
+ for (; t < e.length && /\s/.test(e.charAt(t)); )
11
+ t += 1;
12
+ return t < e.length;
13
+ }
14
+ function s() {
15
+ return l = e.charAt(t), l !== "=" && l !== ";" && l !== ",";
16
+ }
17
+ for (; t < e.length; ) {
18
+ for (a = t, u = !1; f(); )
19
+ if (l = e.charAt(t), l === ",") {
20
+ for (r = t, t += 1, f(), n = t; t < e.length && s(); )
21
+ t += 1;
22
+ t < e.length && e.charAt(t) === "=" ? (u = !0, t = n, h.push(e.substring(a, r)), a = t) : t = r + 1;
23
+ } else
24
+ t += 1;
25
+ (!u || t >= e.length) && h.push(e.substring(a, e.length));
26
+ }
27
+ return h;
28
+ }
29
+ export {
30
+ p as cookie,
31
+ p as default,
32
+ A as splitCookiesString
33
+ };
@@ -0,0 +1,116 @@
1
+ const w = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, g = /^[\u0021-\u003A\u003C-\u007E]*$/, S = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, E = /^[\u0020-\u003A\u003D-\u007E]*$/, v = Object.prototype.toString, b = /* @__PURE__ */ (() => {
2
+ const r = function() {
3
+ };
4
+ return r.prototype = /* @__PURE__ */ Object.create(null), r;
5
+ })();
6
+ function k(r, i) {
7
+ const e = new b(), a = r.length;
8
+ if (a < 2) return e;
9
+ const c = (i == null ? void 0 : i.decode) || p;
10
+ let t = 0;
11
+ do {
12
+ const n = r.indexOf("=", t);
13
+ if (n === -1) break;
14
+ const d = r.indexOf(";", t), u = d === -1 ? a : d;
15
+ if (n > u) {
16
+ t = r.lastIndexOf(";", n - 1) + 1;
17
+ continue;
18
+ }
19
+ const o = m(r, t, n), h = x(r, n, o), l = r.slice(o, h);
20
+ if (e[l] === void 0) {
21
+ const f = m(r, n + 1, u), y = x(r, u, f), s = c(r.slice(f, y));
22
+ e[l] = s;
23
+ }
24
+ t = u + 1;
25
+ } while (t < a);
26
+ return e;
27
+ }
28
+ function m(r, i, e) {
29
+ do {
30
+ const a = r.charCodeAt(i);
31
+ if (a !== 32 && a !== 9) return i;
32
+ } while (++i < e);
33
+ return e;
34
+ }
35
+ function x(r, i, e) {
36
+ for (; i > e; ) {
37
+ const a = r.charCodeAt(--i);
38
+ if (a !== 32 && a !== 9) return i + 1;
39
+ }
40
+ return e;
41
+ }
42
+ function $(r, i, e) {
43
+ const a = (e == null ? void 0 : e.encode) || encodeURIComponent;
44
+ if (!w.test(r))
45
+ throw new TypeError(`argument name is invalid: ${r}`);
46
+ const c = a(i);
47
+ if (!g.test(c))
48
+ throw new TypeError(`argument val is invalid: ${i}`);
49
+ let t = r + "=" + c;
50
+ if (!e) return t;
51
+ if (e.maxAge !== void 0) {
52
+ if (!Number.isInteger(e.maxAge))
53
+ throw new TypeError(`option maxAge is invalid: ${e.maxAge}`);
54
+ t += "; Max-Age=" + e.maxAge;
55
+ }
56
+ if (e.domain) {
57
+ if (!S.test(e.domain))
58
+ throw new TypeError(`option domain is invalid: ${e.domain}`);
59
+ t += "; Domain=" + e.domain;
60
+ }
61
+ if (e.path) {
62
+ if (!E.test(e.path))
63
+ throw new TypeError(`option path is invalid: ${e.path}`);
64
+ t += "; Path=" + e.path;
65
+ }
66
+ if (e.expires) {
67
+ if (!I(e.expires) || !Number.isFinite(e.expires.valueOf()))
68
+ throw new TypeError(`option expires is invalid: ${e.expires}`);
69
+ t += "; Expires=" + e.expires.toUTCString();
70
+ }
71
+ if (e.httpOnly && (t += "; HttpOnly"), e.secure && (t += "; Secure"), e.partitioned && (t += "; Partitioned"), e.priority)
72
+ switch (typeof e.priority == "string" ? e.priority.toLowerCase() : void 0) {
73
+ case "low":
74
+ t += "; Priority=Low";
75
+ break;
76
+ case "medium":
77
+ t += "; Priority=Medium";
78
+ break;
79
+ case "high":
80
+ t += "; Priority=High";
81
+ break;
82
+ default:
83
+ throw new TypeError(`option priority is invalid: ${e.priority}`);
84
+ }
85
+ if (e.sameSite)
86
+ switch (typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite) {
87
+ case !0:
88
+ case "strict":
89
+ t += "; SameSite=Strict";
90
+ break;
91
+ case "lax":
92
+ t += "; SameSite=Lax";
93
+ break;
94
+ case "none":
95
+ t += "; SameSite=None";
96
+ break;
97
+ default:
98
+ throw new TypeError(`option sameSite is invalid: ${e.sameSite}`);
99
+ }
100
+ return t;
101
+ }
102
+ function p(r) {
103
+ if (r.indexOf("%") === -1) return r;
104
+ try {
105
+ return decodeURIComponent(r);
106
+ } catch {
107
+ return r;
108
+ }
109
+ }
110
+ function I(r) {
111
+ return v.call(r) === "[object Date]";
112
+ }
113
+ export {
114
+ k as parse,
115
+ $ as serialize
116
+ };