@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.
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,117 @@
1
+ var k = (i) => {
2
+ throw TypeError(i);
3
+ };
4
+ var _ = (i, n, t) => n.has(i) || k("Cannot " + t);
5
+ var e = (i, n, t) => (_(i, n, "read from private field"), t ? t.call(i) : n.get(i)), c = (i, n, t) => n.has(i) ? k("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(i) : n.set(i, t), r = (i, n, t, h) => (_(i, n, "write to private field"), h ? h.call(i, t) : n.set(i, t), t);
6
+ var O = (i, n, t, h) => ({
7
+ set _(s) {
8
+ r(i, n, s, t);
9
+ },
10
+ get _() {
11
+ return e(i, n, h);
12
+ }
13
+ });
14
+ import "../is/index.js";
15
+ import b from "lodash/isRegExp.js";
16
+ import U from "lodash/isString.js";
17
+ const E = window.WebSocket, C = {};
18
+ function x(i = {}) {
19
+ var n;
20
+ for (const t in C) {
21
+ const h = C[t];
22
+ let s = h == null ? void 0 : h.url, o = !1;
23
+ if (b(s) && (o = (n = s == null ? void 0 : s.test) == null ? void 0 : n.call(s, i.url)), U(s) && (s === "*" ? o = !0 : o = s === i.url), o)
24
+ return h;
25
+ }
26
+ }
27
+ var g, w, v, l, S, p, d, y;
28
+ const I = class I extends EventTarget {
29
+ constructor(t, h) {
30
+ var s, o;
31
+ super();
32
+ c(this, g, -1);
33
+ c(this, w, -1);
34
+ c(this, v, E.CONNECTING);
35
+ c(this, l, null);
36
+ c(this, S, null);
37
+ c(this, p, 0);
38
+ c(this, d, []);
39
+ c(this, y, null);
40
+ if (r(this, l, x({ url: t })), e(this, l))
41
+ r(this, v, E.OPEN), r(this, g, setTimeout(
42
+ () => {
43
+ var a;
44
+ let u = new CustomEvent("open", {});
45
+ this.dispatchEvent(u), (a = this.onopen) == null || a.call(this, u), clearTimeout(e(this, g));
46
+ },
47
+ ((s = e(this, l)) == null ? void 0 : s.openTimeout) ?? Math.random() * 27
48
+ )), r(this, w, setInterval(
49
+ () => {
50
+ this.readyState === E.OPEN && e(this, d).length && (this.send(e(this, y)), O(this, p)._++);
51
+ },
52
+ ((o = e(this, l)) == null ? void 0 : o.messageTimeInterval) ?? 3e3
53
+ ));
54
+ else
55
+ return r(this, S, new E(t, h));
56
+ }
57
+ get readyState() {
58
+ return e(this, l) ? e(this, v) : super.readyState;
59
+ }
60
+ close(t, h) {
61
+ var s, o, u;
62
+ if (e(this, l)) {
63
+ if (this.readyState !== E.CLOSED) {
64
+ r(this, v, E.CLOSED);
65
+ let a = new CloseEvent("close");
66
+ this.dispatchEvent(a), (s = this.onclose) == null || s.call(this, a);
67
+ }
68
+ clearTimeout(e(this, g)), clearInterval(e(this, w)), r(this, p, 0), r(this, d, []);
69
+ } else
70
+ (u = (o = e(this, S)) == null ? void 0 : o.close) == null || u.call(o, t, h);
71
+ }
72
+ send(t) {
73
+ var h, s, o, u;
74
+ if (e(this, l)) {
75
+ r(this, y, t);
76
+ let a = null;
77
+ try {
78
+ a = t && JSON.parse(t);
79
+ } catch (m) {
80
+ console.error(m);
81
+ }
82
+ a != null && a.mockAutoUpdateKey && !e(this, d).find(
83
+ (m) => m.mockAutoUpdateKey === a.mockAutoUpdateKey
84
+ ) && e(this, d).push(a);
85
+ const f = (h = e(this, l)) == null ? void 0 : h.template;
86
+ if (e(this, d).length)
87
+ e(this, d).forEach((m) => {
88
+ var T;
89
+ let N = new MessageEvent("message", {
90
+ data: (f == null ? void 0 : f({ ...m, sendCount: e(this, p) })) ?? f
91
+ });
92
+ this.dispatchEvent(N), (T = this.onmessage) == null || T.call(this, N);
93
+ });
94
+ else {
95
+ let m = new MessageEvent("message", {
96
+ data: (f == null ? void 0 : f({ ...a, sendCount: e(this, p) })) ?? f
97
+ });
98
+ this.dispatchEvent(m), (s = this.onmessage) == null || s.call(this, m);
99
+ }
100
+ } else
101
+ (u = (o = e(this, S)) == null ? void 0 : o.send) == null || u.call(o, t);
102
+ }
103
+ static add(t, h, s) {
104
+ t && (window.WebSocket = I, C[t.toString()] = {
105
+ url: t,
106
+ template: h,
107
+ ...s
108
+ });
109
+ }
110
+ };
111
+ g = new WeakMap(), w = new WeakMap(), v = new WeakMap(), l = new WeakMap(), S = new WeakMap(), p = new WeakMap(), d = new WeakMap(), y = new WeakMap();
112
+ let D = I;
113
+ export {
114
+ D as MockWebSocket,
115
+ E as WebSocketNative,
116
+ D as default
117
+ };
@@ -0,0 +1,94 @@
1
+ var q = (e) => {
2
+ throw TypeError(e);
3
+ };
4
+ var T = (e, n, t) => n.has(e) || q("Cannot " + t);
5
+ var i = (e, n, t) => (T(e, n, "read from private field"), t ? t.call(e) : n.get(e)), a = (e, n, t) => n.has(e) ? q("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), h = (e, n, t, s) => (T(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), y = (e, n, t) => (T(e, n, "access private method"), t);
6
+ import "../is/index.js";
7
+ import D from "lodash/isRegExp.js";
8
+ import L from "lodash/isString.js";
9
+ const E = window.XMLHttpRequest, R = {};
10
+ function M(e = {}) {
11
+ var t, s, r, c, m;
12
+ const n = (s = (t = e.method) == null ? void 0 : t.toLowerCase) == null ? void 0 : s.call(t);
13
+ for (const _ in R) {
14
+ const d = R[_];
15
+ let u = d == null ? void 0 : d.url, f = ((c = (r = d == null ? void 0 : d.method) == null ? void 0 : r.toLowerCase) == null ? void 0 : c.call(r)) === n;
16
+ if (f && (D(u) && (f = (m = u == null ? void 0 : u.test) == null ? void 0 : m.call(u, e.url)), L(u) && (u === "*" ? f = !0 : f = u === e.url)), f)
17
+ return d;
18
+ }
19
+ }
20
+ var o, l, g, w, p, v, C, x;
21
+ const N = class N extends E {
22
+ constructor(t) {
23
+ super(t);
24
+ a(this, C);
25
+ a(this, o, null);
26
+ a(this, l, {
27
+ method: "",
28
+ url: "",
29
+ async: !0,
30
+ username: null,
31
+ password: null
32
+ });
33
+ a(this, g, E.UNSENT);
34
+ a(this, w, "");
35
+ a(this, p, E.UNSENT);
36
+ a(this, v, null);
37
+ }
38
+ open(t, s, r = !0, c = null, m = null) {
39
+ h(this, l, { method: t, url: s, async: r, username: c, password: m }), h(this, o, M(i(this, l))), super.open(t, s, r, c, m), i(this, o) && (h(this, p, E.OPENED), this.dispatchEvent(new CustomEvent("readystatechange", {})));
40
+ }
41
+ get status() {
42
+ return i(this, o) ? i(this, g) : super.status;
43
+ }
44
+ get statusText() {
45
+ return i(this, o) ? i(this, w) : super.statusText;
46
+ }
47
+ get readyState() {
48
+ return i(this, o) ? i(this, p) : super.readyState;
49
+ }
50
+ get response() {
51
+ return i(this, o) ? i(this, v) : super.response;
52
+ }
53
+ get responseText() {
54
+ let t = super.responseText;
55
+ if (i(this, o))
56
+ try {
57
+ t = JSON.stringify(this.response) ?? t;
58
+ } catch (s) {
59
+ t = super.responseText, console.error(s);
60
+ }
61
+ return t;
62
+ }
63
+ send(t) {
64
+ if (i(this, o))
65
+ if (i(this, l).async) {
66
+ const s = setTimeout(() => {
67
+ y(this, C, x).call(this, t), clearTimeout(s);
68
+ }, Math.random() * 227);
69
+ } else
70
+ y(this, C, x).call(this, t);
71
+ else
72
+ super.send(t);
73
+ }
74
+ static add(t, s = "", r, c) {
75
+ t && (window.XMLHttpRequest = N, R[t + s] = {
76
+ url: t,
77
+ method: s,
78
+ template: r,
79
+ ...c
80
+ });
81
+ }
82
+ };
83
+ o = new WeakMap(), l = new WeakMap(), g = new WeakMap(), w = new WeakMap(), p = new WeakMap(), v = new WeakMap(), C = new WeakSet(), x = function(t) {
84
+ var r;
85
+ this.setRequestHeader("X-Requested-With", "PqbMockXMLHttpRequest"), this.dispatchEvent(new CustomEvent("loadstart", {})), h(this, p, E.HEADERS_RECEIVED), this.dispatchEvent(new CustomEvent("readystatechange", {})), h(this, p, E.LOADING), this.dispatchEvent(new CustomEvent("readystatechange", {})), h(this, g, 200), h(this, w, "OK");
86
+ const s = (r = i(this, o)) == null ? void 0 : r.template;
87
+ h(this, v, (s == null ? void 0 : s({ ...i(this, l), body: t })) ?? s), h(this, p, E.DONE), this.dispatchEvent(new CustomEvent("readystatechange", {})), this.dispatchEvent(new CustomEvent("load", {})), this.dispatchEvent(new CustomEvent("loadend", {}));
88
+ };
89
+ let S = N;
90
+ export {
91
+ S as MockXMLHttpRequest,
92
+ E as XMLHttpRequestNative,
93
+ S as default
94
+ };
package/mock/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import { MockWebSocket as o, WebSocketNative as c } from "./MockWebSocket.js";
2
+ import { MockXMLHttpRequest as p, XMLHttpRequestNative as r } from "./MockXMLHttpRequest.js";
3
+ export {
4
+ o as MockWebSocket,
5
+ p as MockXMLHttpRequest,
6
+ c as WebSocketNative,
7
+ r as XMLHttpRequestNative
8
+ };
@@ -0,0 +1,11 @@
1
+ const e = !!(typeof window < "u" && window.document && window.document.createElement), n = {
2
+ canUseDOM: e,
3
+ canUseWorkers: typeof Worker < "u",
4
+ canUseEventListeners: e && !!(window.addEventListener || window.attachEvent),
5
+ canUseViewport: e && !!window.screen,
6
+ isInWorker: !e
7
+ // For now, this is true - might change in the future.
8
+ };
9
+ export {
10
+ n as default
11
+ };
@@ -0,0 +1,146 @@
1
+ let N = !1, i, s, u, o, d, w, l, c, p, _, b, x, f, F, A;
2
+ function r() {
3
+ if (N)
4
+ return;
5
+ N = !0;
6
+ const t = navigator.userAgent;
7
+ let e = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(
8
+ t
9
+ );
10
+ const n = /(Mac OS X)|(Windows)|(Linux)/.exec(t);
11
+ if (x = /\b(iPhone|iP[ao]d)/.exec(t), f = /\b(iP[ao]d)/.exec(t), _ = /Android/i.exec(t), F = /FBAN\/\w+;/i.exec(t), A = /Mobile/i.exec(t), b = !!/Win64/.exec(t), e) {
12
+ i = e[1] ? parseFloat(e[1]) : e[5] ? parseFloat(e[5]) : NaN, i && document && document.documentMode && (i = document.documentMode);
13
+ const a = /(?:Trident\/(\d+.\d+))/.exec(t);
14
+ w = a ? parseFloat(a[1]) + 4 : i, s = e[2] ? parseFloat(e[2]) : NaN, u = e[3] ? parseFloat(e[3]) : NaN, o = e[4] ? parseFloat(e[4]) : NaN, o ? (e = /(?:Chrome\/(\d+\.\d+))/.exec(t), d = e && e[1] ? parseFloat(e[1]) : NaN) : d = NaN;
15
+ } else
16
+ i = s = u = d = o = NaN;
17
+ if (n) {
18
+ if (n[1]) {
19
+ const a = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(t);
20
+ l = a ? parseFloat(a[1].replace("_", ".")) : !0;
21
+ } else
22
+ l = !1;
23
+ c = !!n[2], p = !!n[3];
24
+ } else
25
+ l = c = p = !1;
26
+ }
27
+ const m = {
28
+ /**
29
+ * Check if the UA is Internet Explorer.
30
+ *
31
+ *
32
+ * @return float|NaN Version number (if match) or NaN.
33
+ */
34
+ ie() {
35
+ return r() || i;
36
+ },
37
+ /**
38
+ * Check if we're in Internet Explorer compatibility mode.
39
+ *
40
+ * @return bool true if in compatibility mode, false if
41
+ * not compatibility mode or not ie
42
+ */
43
+ ieCompatibilityMode() {
44
+ return r() || w > i;
45
+ },
46
+ /**
47
+ * Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
48
+ * only need this because Skype can't handle 64-bit IE yet. We need to remove
49
+ * this when we don't need it -- tracked by #601957.
50
+ */
51
+ ie64() {
52
+ return m.ie() && b;
53
+ },
54
+ /**
55
+ * Check if the UA is Firefox.
56
+ *
57
+ *
58
+ * @return float|NaN Version number (if match) or NaN.
59
+ */
60
+ firefox() {
61
+ return r() || s;
62
+ },
63
+ /**
64
+ * Check if the UA is Opera.
65
+ *
66
+ *
67
+ * @return float|NaN Version number (if match) or NaN.
68
+ */
69
+ opera() {
70
+ return r() || u;
71
+ },
72
+ /**
73
+ * Check if the UA is WebKit.
74
+ *
75
+ *
76
+ * @return float|NaN Version number (if match) or NaN.
77
+ */
78
+ webkit() {
79
+ return r() || o;
80
+ },
81
+ /**
82
+ * For Push
83
+ * WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
84
+ */
85
+ safari() {
86
+ return m.webkit();
87
+ },
88
+ /**
89
+ * Check if the UA is a Chrome browser.
90
+ *
91
+ *
92
+ * @return float|NaN Version number (if match) or NaN.
93
+ */
94
+ chrome() {
95
+ return r() || d;
96
+ },
97
+ /**
98
+ * Check if the user is running Windows.
99
+ *
100
+ * @return bool `true' if the user's OS is Windows.
101
+ */
102
+ windows() {
103
+ return r() || c;
104
+ },
105
+ /**
106
+ * Check if the user is running Mac OS X.
107
+ *
108
+ * @return float|bool Returns a float if a version number is detected,
109
+ * otherwise true/false.
110
+ */
111
+ osx() {
112
+ return r() || l;
113
+ },
114
+ /**
115
+ * Check if the user is running Linux.
116
+ *
117
+ * @return bool `true' if the user's OS is some flavor of Linux.
118
+ */
119
+ linux() {
120
+ return r() || p;
121
+ },
122
+ /**
123
+ * Check if the user is running on an iPhone or iPod platform.
124
+ *
125
+ * @return bool `true' if the user is running some flavor of the
126
+ * iPhone OS.
127
+ */
128
+ iphone() {
129
+ return r() || x;
130
+ },
131
+ mobile() {
132
+ return r() || x || f || _ || A;
133
+ },
134
+ nativeApp() {
135
+ return r() || F;
136
+ },
137
+ android() {
138
+ return r() || _;
139
+ },
140
+ ipad() {
141
+ return r() || f;
142
+ }
143
+ };
144
+ export {
145
+ m as default
146
+ };
@@ -0,0 +1,13 @@
1
+ import r from "./UserAgent_DEPRECATED.js";
2
+ import d from "./isEventSupported.js";
3
+ const o = 10, s = 40, t = 800;
4
+ function p(i) {
5
+ let f = 0, l = 0, e = 0, a = 0;
6
+ return "detail" in i && (l = i.detail), "wheelDelta" in i && (l = -i.wheelDelta / 120), "wheelDeltaY" in i && (l = -i.wheelDeltaY / 120), "wheelDeltaX" in i && (f = -i.wheelDeltaX / 120), "axis" in i && i.axis === i.HORIZONTAL_AXIS && (f = l, l = 0), e = f * o, a = l * o, "deltaY" in i && (a = i.deltaY), "deltaX" in i && (e = i.deltaX), (e || a) && i.deltaMode && (i.deltaMode == 1 ? (e *= s, a *= s) : (e *= t, a *= t)), e && !f && (f = e < 1 ? -1 : 1), a && !l && (l = a < 1 ? -1 : 1), { spinX: f, spinY: l, pixelX: e, pixelY: a };
7
+ }
8
+ p.getEventType = function() {
9
+ return r.firefox() ? "DOMMouseScroll" : d("wheel") ? "wheel" : "mousewheel";
10
+ };
11
+ export {
12
+ p as default
13
+ };
@@ -0,0 +1,33 @@
1
+ import i from "./ExecutionEnvironment.js";
2
+ let u;
3
+ i.canUseDOM && (u = document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard.
4
+ // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
5
+ document.implementation.hasFeature("", "") !== !0);
6
+ /**
7
+ * Checks if an event is supported in the current execution environment.
8
+ *
9
+ * NOTE: This will not work correctly for non-generic events such as `change`,
10
+ * `reset`, `load`, `error`, and `select`.
11
+ *
12
+ * Borrows from Modernizr.
13
+ *
14
+ * @param {string} eventNameSuffix Event name, e.g. "click".
15
+ * @param {?boolean} capture Check if the capture phase is supported.
16
+ * @return {boolean} True if the event is supported.
17
+ * @internal
18
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
19
+ */
20
+ function a(n, m) {
21
+ if (!i.canUseDOM || m && !("addEventListener" in document))
22
+ return !1;
23
+ const t = "on" + n;
24
+ let e = t in document;
25
+ if (!e) {
26
+ const o = document.createElement("div");
27
+ o.setAttribute(t, "return;"), e = typeof o[t] == "function";
28
+ }
29
+ return !e && u && n === "wheel" && (e = document.implementation.hasFeature("Events.wheel", "3.0")), e;
30
+ }
31
+ export {
32
+ a as default
33
+ };
package/nzh/cn.js ADDED
@@ -0,0 +1,7 @@
1
+ import { getNzhObjByLang as o } from "./src/autoGet.js";
2
+ import r from "./src/langs/cn_b.js";
3
+ import t from "./src/langs/cn_s.js";
4
+ const f = o(t, r);
5
+ export {
6
+ f as default
7
+ };
package/nzh/hk.js ADDED
@@ -0,0 +1,7 @@
1
+ import { getNzhObjByLang as o } from "./src/autoGet.js";
2
+ import r from "./src/langs/hk_b.js";
3
+ import t from "./src/langs/hk_s.js";
4
+ const p = o(t, r);
5
+ export {
6
+ p as default
7
+ };
package/nzh/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { default as o } from "./nzh.js";
2
+ export {
3
+ o as default
4
+ };
package/nzh/nzh.js ADDED
@@ -0,0 +1,22 @@
1
+ import { CL as i, unCL as p, toMoney as u } from "./src/index.js";
2
+ import { getNzhObjByLang as n } from "./src/autoGet.js";
3
+ import r from "./src/langs/cn_b.js";
4
+ import e from "./src/langs/cn_s.js";
5
+ import m from "./src/langs/hk_b.js";
6
+ import s from "./src/langs/hk_s.js";
7
+ const f = { s: e, b: r, hk_s: s, hk_b: m };
8
+ function o(t) {
9
+ this.lang = t, this.encode = function() {
10
+ return i.apply(t, arguments);
11
+ }, this.decode = function() {
12
+ return p.apply(t, arguments);
13
+ }, this.toMoney = function() {
14
+ return u.apply(t, arguments);
15
+ };
16
+ }
17
+ o.langs = f;
18
+ o.cn = n(e, r);
19
+ o.hk = n(s, m);
20
+ export {
21
+ o as default
22
+ };
@@ -0,0 +1,25 @@
1
+ import { toMoney as d, unCL as c, CL as f } from "./index.js";
2
+ import { extend as n } from "./utils.js";
3
+ function l(u, t) {
4
+ return {
5
+ encodeS: function(r, e) {
6
+ return e = n({ ww: !0, tenMin: !0 }, e), f.call(u, r, e);
7
+ },
8
+ encodeB: function(r, e) {
9
+ return e = n({ ww: !0 }, e), f.call(t, r, e);
10
+ },
11
+ decodeS: function() {
12
+ return c.apply(u, arguments);
13
+ },
14
+ decodeB: function() {
15
+ return c.apply(t, arguments);
16
+ },
17
+ toMoney: function(r, e) {
18
+ return e = n({ ww: !0 }, e), d.call(t, r, e);
19
+ }
20
+ };
21
+ }
22
+ export {
23
+ l as default,
24
+ l as getNzhObjByLang
25
+ };
@@ -0,0 +1,93 @@
1
+ import { getNumbResult as R, clearZero as Y, unshiftZero as L, centerArray as j, extend as E, getDigit as C } from "./utils.js";
2
+ function z(m, h) {
3
+ let _ = R(m);
4
+ if (!_)
5
+ return m;
6
+ h = h || {};
7
+ let i = this.ch, s = this.ch_u, g = this.ch_f || "", r = this.ch_d || ".", x = i.charAt(0), d = _.int, l = _.decimal, f = _.minus, n = "", t = "", y = f ? g : "", u = function c(e, A, o) {
8
+ e = R(e).int;
9
+ let a = "", b = arguments.length > 1 ? arguments[1] : h.tenMin, S = e.length;
10
+ if (S == 1) return i.charAt(+e);
11
+ if (S <= 4)
12
+ for (let O = 0, w = S; w--; ) {
13
+ let Z = +e.charAt(O);
14
+ a += b && S == 2 && O == 0 && Z == 1 ? "" : i.charAt(Z), a += Z && w ? s.charAt(w) : "", O++;
15
+ }
16
+ else {
17
+ let O = e.length / 4 >> 0, w = e.length % 4;
18
+ for (; w == 0 || !s.charAt(3 + O); )
19
+ w += 4, O--;
20
+ let Z = e.substring(0, 0 + w), I = e.substring(w);
21
+ a = c(Z, b) + s.charAt(3 + O) + (I.charAt(0) == "0" ? x : "") + //单位后有0则加零
22
+ c(I, I.length > 4 ? b : !1);
23
+ }
24
+ return a = Y(a, x), a;
25
+ };
26
+ if (l) {
27
+ l = Y(l, "0", "$");
28
+ for (let c = 0; c < l.length; c++)
29
+ t += i.charAt(+l.charAt(c));
30
+ t = t ? r + t : "";
31
+ }
32
+ if (n = u(d), h.ww && s.length > 5) {
33
+ let c = s.charAt(4), e = s.charAt(5), A = n.lastIndexOf(e);
34
+ ~A && (n = n.substring(0, A).replace(new RegExp(e, "g"), c + c) + n.substring(A));
35
+ }
36
+ return y + n + t;
37
+ }
38
+ function $(m, h) {
39
+ m = m.toString();
40
+ let _ = m.split(this.ch_d), i = _[0].replace(this.ch_f, ""), s = _[1], g = !!~_[0].indexOf(this.ch_f), r = this.ch_u.charAt(1), x = this.ch_u.charAt(4), d = this.ch_u.charAt(5);
41
+ i = i.replace(new RegExp(x + "{2}(?!" + x + ")", "g"), d);
42
+ let l = i.split(""), f = 0, n = 0, t = [], y = [], u = [];
43
+ for (let e = 0; e < l.length; e++) {
44
+ let A = l[e], o = 0, a = 0;
45
+ if (~(o = this.ch.indexOf(A)))
46
+ o > 0 && u.unshift(o);
47
+ else if (~(a = this.ch_u.indexOf(A))) {
48
+ let b = C(a);
49
+ f > a ? (L(u, b), j(y, u)) : a >= n ? (e == 0 && (u = [1]), j(t, y, u), t.length > 0 && L(t, b), n = a) : (u.length == 0 && r == A && (u = [1]), j(y, u), L(y, C(a)), f = a);
50
+ }
51
+ }
52
+ j(t, y, u).reverse(), t.length == 0 && t.push(0);
53
+ let c = 0;
54
+ if (s) {
55
+ t.push("."), c = "0.";
56
+ for (let e = 0; e < s.length; e++)
57
+ c += this.ch.indexOf(s.charAt(e)), t.push(this.ch.indexOf(s.charAt(e)));
58
+ c = +c;
59
+ }
60
+ return g && t.unshift("-"), h && h.outputString ? t.join("") : parseFloat(t.join(""));
61
+ }
62
+ function k(m, h) {
63
+ let _ = {
64
+ ww: !0,
65
+ complete: !1,
66
+ outSymbol: !0,
67
+ unOmitYuan: !1,
68
+ forceZheng: !1
69
+ }, i = R(m), s = this.ch.charAt(0);
70
+ if (h = typeof h == "object" ? h : {}, !i)
71
+ return m;
72
+ h = E(_, h);
73
+ let g = i.int, r = i.decimal || "", x = h.outSymbol ? this.m_t : "", d = i.minus ? this.ch_f : "", l = "";
74
+ if (h.complete) {
75
+ for (let f = 1; f < this.m_u.length; f++)
76
+ l += z.call(this, r.charAt(f - 1) || "0") + this.m_u.charAt(f);
77
+ d += z.call(this, g, h) + this.m_u.charAt(0);
78
+ } else {
79
+ let f = h.unOmitYuan || g !== "0";
80
+ if (r = r.substring(0, 0 + (this.m_u.length - 1)), r = Y(r, "0", "$"), r) {
81
+ let n;
82
+ for (let t = 0; t < this.m_u.length - 1; t++)
83
+ r.charAt(t) && r.charAt(t) != "0" && (l += z.call(this, r.charAt(t)) + this.m_u.charAt(t + 1), n = !1), r.charAt(t) === "0" && !n && ((t != 0 || g !== "0") && (l += s), n = !0);
84
+ }
85
+ (f || !l) && (d += z.call(this, g, h) + this.m_u.charAt(0)), h.forceZheng ? (l == "" || l.charAt(l.length - 1) !== this.m_u[2]) && (l += this.m_z) : d += i.decimal ? "" : this.m_z, h.forceZheng;
86
+ }
87
+ return x + d + l;
88
+ }
89
+ export {
90
+ z as CL,
91
+ k as toMoney,
92
+ $ as unCL
93
+ };
@@ -0,0 +1,12 @@
1
+ const _ = {
2
+ ch: "零壹贰叁肆伍陆柒捌玖",
3
+ ch_u: "个拾佰仟万亿",
4
+ ch_f: "负",
5
+ ch_d: "点",
6
+ m_t: "人民币",
7
+ m_z: "整",
8
+ m_u: "元角分"
9
+ };
10
+ export {
11
+ _ as default
12
+ };
@@ -0,0 +1,9 @@
1
+ const c = {
2
+ ch: "零一二三四五六七八九",
3
+ ch_u: "个十百千万亿",
4
+ ch_f: "负",
5
+ ch_d: "点"
6
+ };
7
+ export {
8
+ c as default
9
+ };
@@ -0,0 +1,12 @@
1
+ const _ = {
2
+ ch: "零壹貳參肆伍陸柒捌玖",
3
+ ch_u: "個拾佰仟萬億",
4
+ ch_f: "負",
5
+ ch_d: "點",
6
+ m_t: "$",
7
+ m_z: "整",
8
+ m_u: "圓角分"
9
+ };
10
+ export {
11
+ _ as default
12
+ };
@@ -0,0 +1,9 @@
1
+ const c = {
2
+ ch: "零一二三四五六七八九",
3
+ ch_u: "個十百千萬億",
4
+ ch_f: "負",
5
+ ch_d: "點"
6
+ };
7
+ export {
8
+ c as default
9
+ };