@unicom-cloud/utils 0.1.0
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/case-name/index.js +23 -0
- package/class-name/index.js +9 -0
- package/clipboard-copy/index.js +41 -0
- package/constant/address.js +5304 -0
- package/constant/chineseCharacters.js +4 -0
- package/constant/constellations.js +17 -0
- package/constant/domain.js +268 -0
- package/constant/identity.js +18 -0
- package/constant/index.js +6 -0
- package/constant/keyboardCode.js +105 -0
- package/constant/licensePlate.js +42 -0
- package/constant/name.js +666 -0
- package/constant/platform.js +20 -0
- package/constant/protocol.js +18 -0
- package/constant/ui.js +17 -0
- package/cookie/index.js +33 -0
- package/cookie/src/index.js +116 -0
- package/decimal/decimal.js +1070 -0
- package/decimal/index.js +5 -0
- package/event-emitter/index.js +57 -0
- package/file/fileToURL.js +26 -0
- package/file/index.js +6 -0
- package/file/saveAs.js +35 -0
- package/filesize/index.js +8 -0
- package/filesize/src/constants.js +71 -0
- package/filesize/src/filesize.js +88 -0
- package/index.js +47 -0
- package/invariant/index.js +21 -0
- package/is/index.js +137 -0
- package/math/index.js +34 -0
- package/md5/index.js +65 -0
- package/mock/MockWebSocket.js +117 -0
- package/mock/MockXMLHttpRequest.js +94 -0
- package/mock/index.js +8 -0
- package/normalize-wheel/ExecutionEnvironment.js +11 -0
- package/normalize-wheel/UserAgent_DEPRECATED.js +146 -0
- package/normalize-wheel/index.js +13 -0
- package/normalize-wheel/isEventSupported.js +33 -0
- package/nzh/cn.js +7 -0
- package/nzh/hk.js +7 -0
- package/nzh/index.js +4 -0
- package/nzh/nzh.js +22 -0
- package/nzh/src/autoGet.js +25 -0
- package/nzh/src/index.js +93 -0
- package/nzh/src/langs/cn_b.js +12 -0
- package/nzh/src/langs/cn_s.js +9 -0
- package/nzh/src/langs/hk_b.js +12 -0
- package/nzh/src/langs/hk_s.js +9 -0
- package/nzh/src/utils.js +71 -0
- package/objectKeysSort.js +7 -0
- package/package.json +1 -0
- package/random/address.js +32 -0
- package/random/constellation.js +8 -0
- package/random/image.js +20 -0
- package/random/index.js +63 -0
- package/random/licensePlate.js +12 -0
- package/random/name.js +25 -0
- package/random/number.js +15 -0
- package/random/text.js +117 -0
- package/random/time.js +8 -0
- package/random/web.js +37 -0
- package/screenfull/index.js +119 -0
- package/tree/index.js +87 -0
- package/turbo-stream/index.js +6 -0
- package/turbo-stream/src/decode.js +284 -0
- package/turbo-stream/src/encode.js +363 -0
- package/turbo-stream/src/shared.js +287 -0
- package/url-toolkit/index.js +8 -0
- package/url-toolkit/src/url-toolkit.js +74 -0
package/cookie/index.js
ADDED
|
@@ -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
|
+
};
|