@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,71 @@
1
+ let g = /^([+-])?0*(\d+)(\.(\d+))?$/, o = /^([+-])?0*(\d+)(\.(\d+))?e(([+-])?(\d+))$/i;
2
+ function c(t) {
3
+ let e = o.exec(t.toString());
4
+ if (!e) return t;
5
+ let n = e[2], r = e[4] || "", i = e[5] ? +e[5] : 0;
6
+ if (i > 0) {
7
+ let l = r.substring(0, 0 + i);
8
+ l = l.length < i ? l + new Array(i - l.length + 1).join("0") : l, r = r.substring(i), n += l;
9
+ } else {
10
+ i = -i;
11
+ let l = n.length - i;
12
+ l = l < 0 ? 0 : l;
13
+ let u = n.substring(l, l + i);
14
+ u = u.length < i ? new Array(i - u.length + 1).join("0") + u : u, n = n.substring(0, l), r = u + r;
15
+ }
16
+ return n = n == "" ? "0" : n, (e[1] == "-" ? "-" : "") + n + (r ? "." + r : "");
17
+ }
18
+ function a(t) {
19
+ let e = g.exec(t.toString());
20
+ if (!e && o.test(t.toString()) && (e = g.exec(c(t.toString()))), e)
21
+ return {
22
+ int: e[2],
23
+ decimal: e[4],
24
+ minus: e[1] == "-",
25
+ num: e.slice(1, 3).join("")
26
+ };
27
+ }
28
+ function f(t, e) {
29
+ if (t.splice.apply(
30
+ t,
31
+ [0, e.length].concat(e.splice(0, e.length))
32
+ ), arguments.length > 2) {
33
+ let n = [].slice.call(arguments, 2);
34
+ n.unshift(t), f.apply(null, n);
35
+ }
36
+ return t;
37
+ }
38
+ function s(t, e) {
39
+ return Object.prototype.hasOwnProperty.call(t, e);
40
+ }
41
+ function h(t) {
42
+ let e, n = arguments[0] || {}, r = Array.prototype.slice.call(arguments, 1);
43
+ for (let i = 0; i < r.length; i++) {
44
+ let l = r[i];
45
+ for (e in l)
46
+ s(l, e) && (n[e] = l[e]);
47
+ }
48
+ return n;
49
+ }
50
+ function p(t) {
51
+ return t >= 5 ? (t - 4) * 4 + 4 : t;
52
+ }
53
+ function x(t, e) {
54
+ if (e == null && (e = 1), !(e <= 0))
55
+ for (; e--; ) t.unshift(0);
56
+ }
57
+ function _(t, e, n) {
58
+ if (t == null) return "";
59
+ let r = ~"*.?+$^[](){}|\\/".indexOf(e) ? "\\" + e : e, i = new RegExp("^" + r + "+"), l = new RegExp(r + "+$"), u = new RegExp(r + "{2}", "g");
60
+ return t = t.toString(), n == "^" && (t = t.replace(i, "")), (!n || n == "$") && (t = t.replace(l, "")), (!n || n == "nto1") && (t = t.replace(u, e)), t;
61
+ }
62
+ export {
63
+ f as centerArray,
64
+ _ as clearZero,
65
+ c as e2ten,
66
+ h as extend,
67
+ p as getDigit,
68
+ a as getNumbResult,
69
+ s as hasAttr,
70
+ x as unshiftZero
71
+ };
@@ -0,0 +1,7 @@
1
+ function s(r) {
2
+ const o = Object.entries(r).sort((t, e) => t[0] === e[0] ? 0 : t[0] > e[0] ? 1 : -1);
3
+ return Object.fromEntries(o);
4
+ }
5
+ export {
6
+ s as default
7
+ };
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name":"@unicom-cloud/utils","version":"0.1.0","dependencies":{},"peerDependencies":{"lodash":"^4.17.21"},"main":"./index.js","type":"module","types":"types/*","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
@@ -0,0 +1,32 @@
1
+ import e from "lodash/sample.js";
2
+ import m, { REGION as a } from "../constant/address.js";
3
+ import i from "./number.js";
4
+ const l = {
5
+ region() {
6
+ return e(a);
7
+ },
8
+ // 随机生成一个(中国)省(或直辖市、自治区、特别行政区)。
9
+ province() {
10
+ return e(m).name;
11
+ },
12
+ // 随机生成一个(中国)市。
13
+ city(t) {
14
+ const n = e(m), r = e(n == null ? void 0 : n.children);
15
+ return t ? `${n.name} ${r.name}` : r.name;
16
+ },
17
+ // 随机生成一个(中国)县。
18
+ county(t) {
19
+ const n = e(m), r = e(n == null ? void 0 : n.children), o = e(r == null ? void 0 : r.children);
20
+ return t ? `${n.name} ${r.name} ${o.name}` : o.name;
21
+ },
22
+ // 随机生成一个邮政编码(六位数字)。
23
+ zip(t) {
24
+ let n = "";
25
+ for (let r = 0; r < (t || 6); r++)
26
+ n += i.natural(0, 9);
27
+ return n;
28
+ }
29
+ };
30
+ export {
31
+ l as default
32
+ };
@@ -0,0 +1,8 @@
1
+ import o from "lodash/sample.js";
2
+ import t from "../constant/constellations.js";
3
+ function m() {
4
+ return o(t);
5
+ }
6
+ export {
7
+ m as default
8
+ };
@@ -0,0 +1,20 @@
1
+ function d(g = {}) {
2
+ let {
3
+ type: r = "image/png",
4
+ quality: s = 1,
5
+ width: c = 400,
6
+ height: l = 300
7
+ } = g ?? {};
8
+ const e = document.createElement("canvas"), t = e.getContext("2d"), x = window.devicePixelRatio || 1, R = t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1, a = x / R;
9
+ e.width = c * a, e.height = l * a, e.style.width = `${c}px`, e.style.height = `${l}px`, t.scale(a, a);
10
+ let i = 10;
11
+ for (let o = 0; o < c / i; o++)
12
+ for (let n = 0; n < l / i; n++)
13
+ t.fillStyle = (o + n) % 2 === 0 ? "#777" : "#888", t.fillRect(i * o, i * n, i, i);
14
+ return e.toDataURL(r, s);
15
+ }
16
+ const h = { generateImageDataURL: d };
17
+ export {
18
+ h as default,
19
+ d as generateImageDataURL
20
+ };
@@ -0,0 +1,63 @@
1
+ import o from "lodash/sample.js";
2
+ import { v4 as p } from "uuid";
3
+ import n from "./address.js";
4
+ import u from "./constellation.js";
5
+ import d from "./image.js";
6
+ import l from "./licensePlate.js";
7
+ import i from "./name.js";
8
+ import r from "./number.js";
9
+ import e from "./text.js";
10
+ import s from "./time.js";
11
+ import m from "./web.js";
12
+ const f = /* @__PURE__ */ (() => {
13
+ let t = 0;
14
+ return () => Date.now() + 19870227 + 19920127 + 202111221054 + 202310310737 + t++;
15
+ })(), v = {
16
+ number: r,
17
+ natural: r.natural.bind(r),
18
+ integer: r.integer.bind(r),
19
+ float: r.float.bind(r),
20
+ boolean() {
21
+ return o([!0, !1]);
22
+ },
23
+ sex() {
24
+ return o(["男", "女"]);
25
+ },
26
+ pick: o,
27
+ text: e,
28
+ ctitle: e.ctitle.bind(e),
29
+ cparagraph: e.cparagraph.bind(e),
30
+ csentence: e.csentence.bind(e),
31
+ cword: e.cword.bind(e),
32
+ name: i,
33
+ cname: i.cname.bind(i),
34
+ web: m,
35
+ phone: m.phone.bind(m),
36
+ address: n,
37
+ county: (t) => n.county(t ?? !0),
38
+ company() {
39
+ return `${n.city()}某某某有限公司`;
40
+ },
41
+ project() {
42
+ return `${n.city()}某某某项目部`;
43
+ },
44
+ time: s,
45
+ constellation: u,
46
+ licensePlate: l,
47
+ uuid() {
48
+ return p();
49
+ },
50
+ id() {
51
+ return f();
52
+ },
53
+ increment: /* @__PURE__ */ ((t) => {
54
+ let a = 0;
55
+ return function(c) {
56
+ return a += +c || 1;
57
+ };
58
+ })(),
59
+ image: d
60
+ };
61
+ export {
62
+ v as default
63
+ };
@@ -0,0 +1,12 @@
1
+ import r from "lodash/sample.js";
2
+ import { PROVINCE_CODE_ARRAY as t } from "../constant/licensePlate.js";
3
+ import e from "./number.js";
4
+ import m from "./text.js";
5
+ function i() {
6
+ return `${r(t)}${m.character(
7
+ "upper"
8
+ )}${e.natural(1e4, 99999)}`;
9
+ }
10
+ export {
11
+ i as default
12
+ };
package/random/name.js ADDED
@@ -0,0 +1,25 @@
1
+ import t from "lodash/sample.js";
2
+ import { LAST_NAME_CHINESE as s, FIRST_NAME_CHINESE as e, LAST_NAME as i, FIRST_NAME as a } from "../constant/name.js";
3
+ const m = {
4
+ first() {
5
+ return t(a);
6
+ },
7
+ last() {
8
+ return t(i);
9
+ },
10
+ name(r) {
11
+ return `${this.first()} ${r ? `${this.first()} ` : ""}${this.last()}`;
12
+ },
13
+ cfirst() {
14
+ return t(e);
15
+ },
16
+ clast() {
17
+ return t(s);
18
+ },
19
+ cname() {
20
+ return this.cfirst() + this.clast();
21
+ }
22
+ };
23
+ export {
24
+ m as default
25
+ };
@@ -0,0 +1,15 @@
1
+ import a from "lodash/random.js";
2
+ const n = {
3
+ natural(t = 0, r = Math.pow(2, 53)) {
4
+ return a(t, r);
5
+ },
6
+ integer(t = -Math.pow(2, 53), r = Math.pow(2, 53)) {
7
+ return this.natural(t, r);
8
+ },
9
+ float(t, r) {
10
+ return a(t, r, !0);
11
+ }
12
+ };
13
+ export {
14
+ n as default
15
+ };
package/random/text.js ADDED
@@ -0,0 +1,117 @@
1
+ import c from "lodash/capitalize.js";
2
+ import i from "../constant/chineseCharacters.js";
3
+ import a from "./number.js";
4
+ function s(t, r, l, e) {
5
+ return l === void 0 ? a.natural(t, r) : e === void 0 ? l : a.natural(parseInt(l, 10), parseInt(e, 10));
6
+ }
7
+ const p = {
8
+ paragraph(t, r) {
9
+ let l = s(3, 7, t, r), e = [];
10
+ for (let n = 0; n < l; n++)
11
+ e.push(this.sentence());
12
+ return e.join(" ");
13
+ },
14
+ cparagraph(t, r) {
15
+ let l = s(3, 7, t, r), e = [];
16
+ for (let n = 0; n < l; n++)
17
+ e.push(this.csentence());
18
+ return e.join("");
19
+ },
20
+ // 随机生成一个句子,第一个单词的首字母大写。
21
+ sentence(t, r) {
22
+ let l = s(12, 18, t, r), e = [];
23
+ for (let n = 0; n < l; n++)
24
+ e.push(this.word());
25
+ return c(e.join(" ")) + ".";
26
+ },
27
+ // 随机生成一个中文句子。
28
+ csentence(t, r) {
29
+ let l = s(12, 18, t, r), e = [];
30
+ for (let n = 0; n < l; n++)
31
+ e.push(this.cword());
32
+ return e.join("") + "。";
33
+ },
34
+ // 随机生成一个单词。
35
+ word(t, r) {
36
+ let l = s(3, 10, t, r), e = "";
37
+ for (let n = 0; n < l; n++)
38
+ e += this.character("lower");
39
+ return e;
40
+ },
41
+ // 随机生成一个或多个汉字。
42
+ cword(t, r, l) {
43
+ let e;
44
+ switch (arguments.length) {
45
+ case 0: {
46
+ t = i, e = 1;
47
+ break;
48
+ }
49
+ case 1: {
50
+ typeof arguments[0] == "string" ? e = 1 : (e = t, t = i);
51
+ break;
52
+ }
53
+ case 2: {
54
+ typeof arguments[0] == "string" ? e = r : (e = a.natural(t, r), t = i);
55
+ break;
56
+ }
57
+ case 3: {
58
+ e = a.natural(r, l);
59
+ break;
60
+ }
61
+ }
62
+ let n = "";
63
+ for (let u = 0; u < e; u++)
64
+ n += t.charAt(a.natural(0, t.length - 1));
65
+ return n;
66
+ },
67
+ // 随机生成一句标题,其中每个单词的首字母大写。
68
+ title(t, r) {
69
+ let l = s(3, 7, t, r), e = [];
70
+ for (let n = 0; n < l; n++)
71
+ e.push(c(this.word()));
72
+ return e.join(" ");
73
+ },
74
+ // 随机生成一句中文标题。
75
+ ctitle(t, r) {
76
+ let l = s(3, 7, t, r), e = [];
77
+ for (let n = 0; n < l; n++)
78
+ e.push(this.cword());
79
+ return e.join("");
80
+ },
81
+ character(t) {
82
+ const r = {
83
+ lower: "abcdefghijklmnopqrstuvwxyz",
84
+ upper: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
85
+ number: "0123456789",
86
+ symbol: "!@#$%^&*()[]"
87
+ };
88
+ r.alpha = r.lower + r.upper;
89
+ let l = r[t] ?? t ?? r.lower + r.upper + r.number + r.symbol;
90
+ return l.charAt(a.natural(0, l.length - 1));
91
+ },
92
+ // 返回一个随机字符串。
93
+ string(t, r, l) {
94
+ let e;
95
+ switch (arguments.length) {
96
+ case 0:
97
+ e = a.natural(3, 7);
98
+ break;
99
+ case 1:
100
+ e = t, t = void 0;
101
+ break;
102
+ case 2:
103
+ typeof arguments[0] == "string" ? e = r : (e = a.natural(t, r), t = void 0);
104
+ break;
105
+ case 3:
106
+ e = a.natural(r, l);
107
+ break;
108
+ }
109
+ let n = "";
110
+ for (let u = 0; u < e; u++)
111
+ n += this.character(t);
112
+ return n;
113
+ }
114
+ };
115
+ export {
116
+ p as default
117
+ };
package/random/time.js ADDED
@@ -0,0 +1,8 @@
1
+ function o(e, t) {
2
+ let n = e ? new Date(e).getTime() : new Date(1987, 1, 27).getTime(), a = t ? new Date(t).getTime() : (/* @__PURE__ */ new Date()).getTime();
3
+ const i = Math.random() * (a - n) + n;
4
+ return new Date(i).toISOString();
5
+ }
6
+ export {
7
+ o as default
8
+ };
package/random/web.js ADDED
@@ -0,0 +1,37 @@
1
+ import n from "lodash/sample.js";
2
+ import u from "../constant/domain.js";
3
+ import e from "../constant/protocol.js";
4
+ import r from "./number.js";
5
+ import o from "./text.js";
6
+ const s = {
7
+ url(t, a) {
8
+ return (t || this.protocol()) + "://" + (a || this.domain()) + "/" + o.word();
9
+ },
10
+ protocol() {
11
+ return n(e);
12
+ },
13
+ domain(t) {
14
+ return o.word() + "." + (t || this.tld());
15
+ },
16
+ tld() {
17
+ return n(u);
18
+ },
19
+ email(t) {
20
+ return o.word() + "@" + (t || o.word() + "." + this.tld());
21
+ },
22
+ phone() {
23
+ return `1${n([3, 5, 6, 7, 8, 9])}${r.natural(
24
+ 1e9,
25
+ 9999999999
26
+ )}`;
27
+ },
28
+ ip() {
29
+ return r.natural(0, 255) + "." + r.natural(0, 255) + "." + r.natural(0, 255) + "." + r.natural(0, 255);
30
+ },
31
+ port() {
32
+ return r.natural(1111, 8888);
33
+ }
34
+ };
35
+ export {
36
+ s as default
37
+ };
@@ -0,0 +1,119 @@
1
+ const o = [
2
+ [
3
+ "requestFullscreen",
4
+ "exitFullscreen",
5
+ "fullscreenElement",
6
+ "fullscreenEnabled",
7
+ "fullscreenchange",
8
+ "fullscreenerror"
9
+ ],
10
+ // New WebKit
11
+ [
12
+ "webkitRequestFullscreen",
13
+ "webkitExitFullscreen",
14
+ "webkitFullscreenElement",
15
+ "webkitFullscreenEnabled",
16
+ "webkitfullscreenchange",
17
+ "webkitfullscreenerror"
18
+ ]
19
+ // Old WebKit
20
+ // [
21
+ // 'webkitRequestFullScreen',
22
+ // 'webkitCancelFullScreen',
23
+ // 'webkitCurrentFullScreenElement',
24
+ // 'webkitCancelFullScreen',
25
+ // 'webkitfullscreenchange',
26
+ // 'webkitfullscreenerror',
27
+ // ],
28
+ // [
29
+ // 'mozRequestFullScreen',
30
+ // 'mozCancelFullScreen',
31
+ // 'mozFullScreenElement',
32
+ // 'mozFullScreenEnabled',
33
+ // 'mozfullscreenchange',
34
+ // 'mozfullscreenerror',
35
+ // ],
36
+ // [
37
+ // 'msRequestFullscreen',
38
+ // 'msExitFullscreen',
39
+ // 'msFullscreenElement',
40
+ // 'msFullscreenEnabled',
41
+ // 'MSFullscreenChange',
42
+ // 'MSFullscreenError',
43
+ // ],
44
+ ], e = Reflect.apply(
45
+ () => {
46
+ if (typeof document > "u")
47
+ return !1;
48
+ const r = o[0], l = {};
49
+ for (const n of o)
50
+ if ((n == null ? void 0 : n[1]) in document) {
51
+ for (const [s, u] of n.entries())
52
+ l[r[s]] = u;
53
+ return l;
54
+ }
55
+ return !1;
56
+ },
57
+ void 0,
58
+ []
59
+ ), f = {
60
+ change: e == null ? void 0 : e.fullscreenchange,
61
+ error: e == null ? void 0 : e.fullscreenerror
62
+ };
63
+ let t = {
64
+ request(r = document.documentElement, l) {
65
+ return new Promise((n, c) => {
66
+ const s = () => {
67
+ t.off("change", s), n();
68
+ };
69
+ t.on("change", s);
70
+ const u = r[e == null ? void 0 : e.requestFullscreen](l);
71
+ u instanceof Promise && u.then(s).catch(c);
72
+ });
73
+ },
74
+ exit() {
75
+ return new Promise((r, l) => {
76
+ if (!t.isFullscreen) {
77
+ r();
78
+ return;
79
+ }
80
+ const n = () => {
81
+ t.off("change", n), r();
82
+ };
83
+ t.on("change", n);
84
+ const c = document[e == null ? void 0 : e.exitFullscreen]();
85
+ c instanceof Promise && c.then(n).catch(l);
86
+ });
87
+ },
88
+ toggle(r, l) {
89
+ return t.isFullscreen ? t.exit() : t.request(r, l);
90
+ },
91
+ on(r, l) {
92
+ const n = f[r];
93
+ n && document.addEventListener(n, l, !1);
94
+ },
95
+ off(r, l) {
96
+ const n = f[r];
97
+ n && document.removeEventListener(n, l, !1);
98
+ },
99
+ raw: e
100
+ };
101
+ Object.defineProperties(t, {
102
+ isFullscreen: {
103
+ get: () => !!document[e == null ? void 0 : e.fullscreenElement]
104
+ },
105
+ element: {
106
+ enumerable: !0,
107
+ get: () => document[e == null ? void 0 : e.fullscreenElement] ?? void 0
108
+ },
109
+ isEnabled: {
110
+ enumerable: !0,
111
+ // Coerce to boolean in case of old WebKit.
112
+ get: () => !!document[e == null ? void 0 : e.fullscreenEnabled]
113
+ }
114
+ });
115
+ e || (t = { isEnabled: !1 });
116
+ const d = t;
117
+ export {
118
+ d as default
119
+ };
package/tree/index.js ADDED
@@ -0,0 +1,87 @@
1
+ function a(e, t, f, l = "children") {
2
+ if (Array.isArray(e) && (e = {
3
+ [l]: e
4
+ }), !(e && typeof e == "object")) return null;
5
+ if (t in e && e[t] === f)
6
+ return e;
7
+ const r = e[l] ?? e.items ?? e.list;
8
+ if (Array.isArray(r))
9
+ for (let i of r) {
10
+ const n = a(i, t, f, l);
11
+ if (n)
12
+ return n;
13
+ }
14
+ return null;
15
+ }
16
+ function y(e, t, f, l = "children") {
17
+ if (!e) return;
18
+ let r = Array.isArray(e) ? [...e] : [e];
19
+ e: for (; r.length; ) {
20
+ let i = r.shift();
21
+ if (!i) continue e;
22
+ if (!Array.isArray(i)) {
23
+ if (i[t] === f)
24
+ return i;
25
+ let n = i[l] ?? i.items ?? i.list;
26
+ if (n === void 0)
27
+ continue e;
28
+ i = n;
29
+ }
30
+ r = r.concat(i);
31
+ }
32
+ }
33
+ const d = a;
34
+ function A(e, t, f, l = "children") {
35
+ if (!e) return;
36
+ const r = Array.isArray(e) ? [...e] : [e];
37
+ e: for (; r.length; ) {
38
+ let i = r.pop();
39
+ if (!i) continue e;
40
+ if (!Array.isArray(i)) {
41
+ if (i[t] === f)
42
+ return i;
43
+ let n = i[l] ?? i.items ?? i.list;
44
+ if (n === void 0)
45
+ continue e;
46
+ i = n;
47
+ }
48
+ if (Array.isArray(i))
49
+ for (let n = 0, u = i.length; n < u; n++)
50
+ r.push(i[u - 1 - n]);
51
+ }
52
+ }
53
+ function h(e, t) {
54
+ return y(e, "id", t);
55
+ }
56
+ function g(e, t, f = !0) {
57
+ var r;
58
+ let l = (r = y(e, "value", t)) == null ? void 0 : r.label;
59
+ return !l && f && (l = t), l;
60
+ }
61
+ function m(e, t, f, l = "children") {
62
+ if (!e) return;
63
+ let r = null;
64
+ function i(n) {
65
+ if (!n) return;
66
+ let u = Array.isArray(n) ? n : n[l] ?? n.items ?? n.list ?? [];
67
+ for (let c = 0; c < u.length; c++) {
68
+ const s = u[c];
69
+ if ((s == null ? void 0 : s[t]) === f) {
70
+ r = { item: s, parent: n, index: c };
71
+ return;
72
+ }
73
+ i(s);
74
+ }
75
+ }
76
+ return i(e), r;
77
+ }
78
+ export {
79
+ y as default,
80
+ a as findNodeBy,
81
+ m as getChildWithParentBy,
82
+ y as getItemBy,
83
+ d as getItemBy2,
84
+ A as getItemBy3,
85
+ h as getItemByID,
86
+ g as getLabelFromDictionaryByValue
87
+ };
@@ -0,0 +1,6 @@
1
+ import { decode as r } from "./src/decode.js";
2
+ import { encode as c } from "./src/encode.js";
3
+ export {
4
+ r as decode,
5
+ c as encode
6
+ };