@unicom-cloud/utils 0.1.11 → 0.1.13

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 (122) hide show
  1. package/date/index.js +22 -0
  2. package/date.js +9 -0
  3. package/filesize/src/constants.js +22 -22
  4. package/filesize/src/filesize.js +32 -33
  5. package/index.js +56 -54
  6. package/lunar/index.js +36 -0
  7. package/lunar/lib/Holiday.js +42 -0
  8. package/lunar/lib/HolidayUtil.js +128 -0
  9. package/lunar/lib/I18n.js +1005 -0
  10. package/lunar/lib/JieQi.js +40 -0
  11. package/lunar/lib/Lunar.js +1035 -0
  12. package/lunar/lib/LunarMonth.js +150 -0
  13. package/lunar/lib/LunarTime.js +138 -0
  14. package/lunar/lib/LunarUtil.js +1752 -0
  15. package/lunar/lib/LunarYear.js +616 -0
  16. package/lunar/lib/ShouXingUtil.js +6915 -0
  17. package/lunar/lib/Solar.js +311 -0
  18. package/lunar/lib/SolarHalfYear.js +45 -0
  19. package/lunar/lib/SolarMonth.js +55 -0
  20. package/lunar/lib/SolarSeason.js +42 -0
  21. package/lunar/lib/SolarUtil.js +256 -0
  22. package/lunar/lib/SolarWeek.js +153 -0
  23. package/lunar/lib/SolarYear.js +35 -0
  24. package/lunar/lib/index.js +35 -0
  25. package/lunar.js +36 -0
  26. package/package.json +1 -1
  27. package/snapdom/src/api/preCache.js +27 -37
  28. package/snapdom/src/api/snapdom.js +75 -58
  29. package/snapdom/src/core/cache.js +19 -8
  30. package/snapdom/src/core/capture.js +49 -48
  31. package/snapdom/src/core/clone.js +96 -31
  32. package/snapdom/src/core/prepare.js +43 -37
  33. package/snapdom/src/modules/background.js +29 -20
  34. package/snapdom/src/modules/fonts.js +94 -104
  35. package/snapdom/src/modules/iconFonts.js +28 -0
  36. package/snapdom/src/modules/images.js +6 -6
  37. package/snapdom/src/modules/pseudo.js +52 -50
  38. package/snapdom/src/modules/styles.js +26 -6
  39. package/snapdom/src/modules/svgDefs.js +26 -0
  40. package/snapdom/src/utils/cssTools.js +41 -41
  41. package/snapdom/src/utils/helpers.js +128 -84
  42. package/tinycolor/index.js +46 -0
  43. package/tinycolor/src/conversion.js +143 -0
  44. package/tinycolor/src/css-color-names.js +153 -0
  45. package/tinycolor/src/format-input.js +77 -0
  46. package/tinycolor/src/from-ratio.js +21 -0
  47. package/tinycolor/src/index.js +404 -0
  48. package/tinycolor/src/random.js +221 -0
  49. package/tinycolor/src/readability.js +37 -0
  50. package/tinycolor/src/to-ms-filter.js +15 -0
  51. package/tinycolor/src/util.js +32 -0
  52. package/tinycolor.js +46 -0
  53. package/tree/index.js +10 -8
  54. package/tree/search/index.js +90 -0
  55. package/tree.js +9 -7
  56. package/types/date/index.d.ts +4 -0
  57. package/types/filesize/src/constants.d.ts +12 -12
  58. package/types/filesize/src/filesize.d.ts +63 -22
  59. package/types/index.d.ts +4 -3
  60. package/types/lunar/index.d.ts +3 -0
  61. package/types/lunar/lib/Holiday.d.ts +17 -0
  62. package/types/lunar/lib/HolidayUtil.d.ts +23 -0
  63. package/types/lunar/lib/I18n.d.ts +23 -0
  64. package/types/lunar/lib/JieQi.d.ts +15 -0
  65. package/types/lunar/lib/Lunar.d.ts +245 -0
  66. package/types/lunar/lib/LunarMonth.d.ts +35 -0
  67. package/types/lunar/lib/LunarTime.d.ts +40 -0
  68. package/types/lunar/lib/LunarUtil.d.ts +128 -0
  69. package/types/lunar/lib/LunarYear.d.ts +61 -0
  70. package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
  71. package/types/lunar/lib/Solar.d.ts +51 -0
  72. package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
  73. package/types/lunar/lib/SolarMonth.d.ts +16 -0
  74. package/types/lunar/lib/SolarSeason.d.ts +15 -0
  75. package/types/lunar/lib/SolarUtil.d.ts +20 -0
  76. package/types/lunar/lib/SolarWeek.d.ts +23 -0
  77. package/types/lunar/lib/SolarYear.d.ts +12 -0
  78. package/types/lunar/lib/index.d.ts +17 -0
  79. package/types/snapdom/src/core/cache.d.ts +17 -11
  80. package/types/snapdom/src/core/capture.d.ts +4 -0
  81. package/types/snapdom/src/core/clone.d.ts +4 -5
  82. package/types/snapdom/src/core/prepare.d.ts +8 -1
  83. package/types/snapdom/src/modules/background.d.ts +1 -2
  84. package/types/snapdom/src/modules/fonts.d.ts +1 -3
  85. package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
  86. package/types/snapdom/src/modules/pseudo.d.ts +1 -3
  87. package/types/snapdom/src/modules/styles.d.ts +1 -10
  88. package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
  89. package/types/snapdom/src/utils/cssTools.d.ts +1 -2
  90. package/types/snapdom/src/utils/helpers.d.ts +1 -1
  91. package/types/tinycolor/index.d.ts +2 -0
  92. package/types/tinycolor/src/conversion.d.ts +79 -0
  93. package/types/tinycolor/src/css-color-names.d.ts +4 -0
  94. package/types/tinycolor/src/format-input.d.ts +38 -0
  95. package/types/tinycolor/src/from-ratio.d.ts +14 -0
  96. package/types/tinycolor/src/index.d.ts +214 -0
  97. package/types/tinycolor/src/interfaces.d.ts +57 -0
  98. package/types/tinycolor/src/public_api.d.ts +10 -0
  99. package/types/tinycolor/src/random.d.ts +24 -0
  100. package/types/tinycolor/src/readability.d.ts +46 -0
  101. package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
  102. package/types/tinycolor/src/umd_api.d.ts +22 -0
  103. package/types/tinycolor/src/util.d.ts +36 -0
  104. package/types/tree/index.d.ts +1 -0
  105. package/types/tree/search/index.d.ts +80 -0
  106. package/types/ui-color/compareColorByRange.d.ts +2 -0
  107. package/types/ui-color/index.d.ts +208 -0
  108. package/ui-color/compareColorByRange.js +9 -0
  109. package/ui-color/index.js +162 -0
  110. package/uiColor.js +29 -0
  111. package/convertTime.js +0 -4
  112. package/dayjs/index.js +0 -15
  113. package/dayjs.js +0 -5
  114. package/lunar-converter/index.js +0 -641
  115. package/lunarConverter.js +0 -4
  116. package/search-tree/index.js +0 -54
  117. package/searchTree.js +0 -4
  118. package/types/dayjs/index.d.ts +0 -1
  119. package/types/lunar-converter/index.d.ts +0 -113
  120. package/types/search-tree/index.d.ts +0 -20
  121. /package/{convert-time/index.js → date/convertTime.js} +0 -0
  122. /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
@@ -0,0 +1,221 @@
1
+ import { TinyColor as l } from "./index.js";
2
+ function g(e = {}) {
3
+ if (e.count !== void 0 && e.count !== null) {
4
+ const a = e.count, u = [];
5
+ for (e.count = void 0; a > u.length; )
6
+ e.count = null, e.seed && (e.seed += 1), u.push(g(e));
7
+ return e.count = a, u;
8
+ }
9
+ const n = w(e.hue, e.seed), o = R(n, e), r = B(n, o, e), t = { h: n, s: o, v: r };
10
+ return e.alpha !== void 0 && (t.a = e.alpha), new l(t);
11
+ }
12
+ function w(e, n) {
13
+ const o = M(e);
14
+ let r = s(o, n);
15
+ return r < 0 && (r = 360 + r), r;
16
+ }
17
+ function R(e, n) {
18
+ if (n.hue === "monochrome")
19
+ return 0;
20
+ if (n.luminosity === "random")
21
+ return s([0, 100], n.seed);
22
+ const { saturationRange: o } = i(e);
23
+ let r = o[0], t = o[1];
24
+ switch (n.luminosity) {
25
+ case "bright":
26
+ r = 55;
27
+ break;
28
+ case "dark":
29
+ r = t - 10;
30
+ break;
31
+ case "light":
32
+ t = 55;
33
+ break;
34
+ }
35
+ return s([r, t], n.seed);
36
+ }
37
+ function B(e, n, o) {
38
+ let r = k(e, n), t = 100;
39
+ switch (o.luminosity) {
40
+ case "dark":
41
+ t = r + 20;
42
+ break;
43
+ case "light":
44
+ r = (t + r) / 2;
45
+ break;
46
+ case "random":
47
+ r = 0, t = 100;
48
+ break;
49
+ }
50
+ return s([r, t], o.seed);
51
+ }
52
+ function k(e, n) {
53
+ const { lowerBounds: o } = i(e);
54
+ for (let r = 0; r < o.length - 1; r++) {
55
+ const t = o[r][0], a = o[r][1], u = o[r + 1][0], d = o[r + 1][1];
56
+ if (n >= t && n <= u) {
57
+ const c = (d - a) / (u - t), m = a - c * t;
58
+ return c * n + m;
59
+ }
60
+ }
61
+ return 0;
62
+ }
63
+ function M(e) {
64
+ const n = parseInt(e, 10);
65
+ if (!Number.isNaN(n) && n < 360 && n > 0)
66
+ return [n, n];
67
+ if (typeof e == "string") {
68
+ const o = f.find((t) => t.name === e);
69
+ if (o) {
70
+ const t = h(o);
71
+ if (t.hueRange)
72
+ return t.hueRange;
73
+ }
74
+ const r = new l(e);
75
+ if (r.isValid) {
76
+ const t = r.toHsv().h;
77
+ return [t, t];
78
+ }
79
+ }
80
+ return [0, 360];
81
+ }
82
+ function i(e) {
83
+ e >= 334 && e <= 360 && (e -= 360);
84
+ for (const n of f) {
85
+ const o = h(n);
86
+ if (o.hueRange && e >= o.hueRange[0] && e <= o.hueRange[1])
87
+ return o;
88
+ }
89
+ throw Error("Color not found");
90
+ }
91
+ function s(e, n) {
92
+ if (n === void 0)
93
+ return Math.floor(e[0] + Math.random() * (e[1] + 1 - e[0]));
94
+ const o = e[1] || 1, r = e[0] || 0;
95
+ n = (n * 9301 + 49297) % 233280;
96
+ const t = n / 233280;
97
+ return Math.floor(r + t * (o - r));
98
+ }
99
+ function h(e) {
100
+ const n = e.lowerBounds[0][0], o = e.lowerBounds[e.lowerBounds.length - 1][0], r = e.lowerBounds[e.lowerBounds.length - 1][1], t = e.lowerBounds[0][1];
101
+ return {
102
+ name: e.name,
103
+ hueRange: e.hueRange,
104
+ lowerBounds: e.lowerBounds,
105
+ saturationRange: [n, o],
106
+ brightnessRange: [r, t]
107
+ };
108
+ }
109
+ const f = [
110
+ {
111
+ name: "monochrome",
112
+ hueRange: null,
113
+ lowerBounds: [
114
+ [0, 0],
115
+ [100, 0]
116
+ ]
117
+ },
118
+ {
119
+ name: "red",
120
+ hueRange: [-26, 18],
121
+ lowerBounds: [
122
+ [20, 100],
123
+ [30, 92],
124
+ [40, 89],
125
+ [50, 85],
126
+ [60, 78],
127
+ [70, 70],
128
+ [80, 60],
129
+ [90, 55],
130
+ [100, 50]
131
+ ]
132
+ },
133
+ {
134
+ name: "orange",
135
+ hueRange: [19, 46],
136
+ lowerBounds: [
137
+ [20, 100],
138
+ [30, 93],
139
+ [40, 88],
140
+ [50, 86],
141
+ [60, 85],
142
+ [70, 70],
143
+ [100, 70]
144
+ ]
145
+ },
146
+ {
147
+ name: "yellow",
148
+ hueRange: [47, 62],
149
+ lowerBounds: [
150
+ [25, 100],
151
+ [40, 94],
152
+ [50, 89],
153
+ [60, 86],
154
+ [70, 84],
155
+ [80, 82],
156
+ [90, 80],
157
+ [100, 75]
158
+ ]
159
+ },
160
+ {
161
+ name: "green",
162
+ hueRange: [63, 178],
163
+ lowerBounds: [
164
+ [30, 100],
165
+ [40, 90],
166
+ [50, 85],
167
+ [60, 81],
168
+ [70, 74],
169
+ [80, 64],
170
+ [90, 50],
171
+ [100, 40]
172
+ ]
173
+ },
174
+ {
175
+ name: "blue",
176
+ hueRange: [179, 257],
177
+ lowerBounds: [
178
+ [20, 100],
179
+ [30, 86],
180
+ [40, 80],
181
+ [50, 74],
182
+ [60, 60],
183
+ [70, 52],
184
+ [80, 44],
185
+ [90, 39],
186
+ [100, 35]
187
+ ]
188
+ },
189
+ {
190
+ name: "purple",
191
+ hueRange: [258, 282],
192
+ lowerBounds: [
193
+ [20, 100],
194
+ [30, 87],
195
+ [40, 79],
196
+ [50, 70],
197
+ [60, 65],
198
+ [70, 59],
199
+ [80, 52],
200
+ [90, 45],
201
+ [100, 42]
202
+ ]
203
+ },
204
+ {
205
+ name: "pink",
206
+ hueRange: [283, 334],
207
+ lowerBounds: [
208
+ [20, 100],
209
+ [30, 90],
210
+ [40, 86],
211
+ [60, 84],
212
+ [80, 80],
213
+ [90, 75],
214
+ [100, 73]
215
+ ]
216
+ }
217
+ ];
218
+ export {
219
+ f as bounds,
220
+ g as random
221
+ };
@@ -0,0 +1,37 @@
1
+ import { TinyColor as a } from "./index.js";
2
+ function i(n, t) {
3
+ const l = new a(n), e = new a(t);
4
+ return (Math.max(l.getLuminance(), e.getLuminance()) + 0.05) / (Math.min(l.getLuminance(), e.getLuminance()) + 0.05);
5
+ }
6
+ function f(n, t, l = { level: "AA", size: "small" }) {
7
+ const e = i(n, t);
8
+ switch ((l.level ?? "AA") + (l.size ?? "small")) {
9
+ case "AAsmall":
10
+ case "AAAlarge":
11
+ return e >= 4.5;
12
+ case "AAlarge":
13
+ return e >= 3;
14
+ case "AAAsmall":
15
+ return e >= 7;
16
+ default:
17
+ return !1;
18
+ }
19
+ }
20
+ function m(n, t, l = {
21
+ includeFallbackColors: !1,
22
+ level: "AA",
23
+ size: "small"
24
+ }) {
25
+ let e = null, c = 0;
26
+ const { includeFallbackColors: o, level: u, size: A } = l;
27
+ for (const s of t) {
28
+ const r = i(n, s);
29
+ r > c && (c = r, e = new a(s));
30
+ }
31
+ return f(n, e, { level: u, size: A }) || !o ? e : (l.includeFallbackColors = !1, m(n, ["#fff", "#000"], l));
32
+ }
33
+ export {
34
+ f as isReadable,
35
+ m as mostReadable,
36
+ i as readability
37
+ };
@@ -0,0 +1,15 @@
1
+ import { rgbaToArgbHex as i } from "./conversion.js";
2
+ import { TinyColor as g } from "./index.js";
3
+ function d(s, o) {
4
+ const r = new g(s), e = `#${i(r.r, r.g, r.b, r.a)}`;
5
+ let n = e;
6
+ const a = r.gradientType ? "GradientType = 1, " : "";
7
+ if (o) {
8
+ const t = new g(o);
9
+ n = `#${i(t.r, t.g, t.b, t.a)}`;
10
+ }
11
+ return `progid:DXImageTransform.Microsoft.gradient(${a}startColorstr=${e},endColorstr=${n})`;
12
+ }
13
+ export {
14
+ d as toMsFilter
15
+ };
@@ -0,0 +1,32 @@
1
+ function o(t, r) {
2
+ i(t) && (t = "100%");
3
+ const e = n(t);
4
+ return t = r === 360 ? t : Math.min(r, Math.max(0, parseFloat(t))), e && (t = parseInt(String(t * r), 10) / 100), Math.abs(t - r) < 1e-6 ? 1 : (r === 360 ? t = (t < 0 ? t % r + r : t % r) / parseFloat(String(r)) : t = t % r / parseFloat(String(r)), t);
5
+ }
6
+ function u(t) {
7
+ return Math.min(1, Math.max(0, t));
8
+ }
9
+ function i(t) {
10
+ return typeof t == "string" && t.indexOf(".") !== -1 && parseFloat(t) === 1;
11
+ }
12
+ function n(t) {
13
+ return typeof t == "string" && t.indexOf("%") !== -1;
14
+ }
15
+ function f(t) {
16
+ return t = parseFloat(t), (isNaN(t) || t < 0 || t > 1) && (t = 1), t;
17
+ }
18
+ function s(t) {
19
+ return Number(t) <= 1 ? `${Number(t) * 100}%` : t;
20
+ }
21
+ function p(t) {
22
+ return t.length === 1 ? "0" + t : String(t);
23
+ }
24
+ export {
25
+ o as bound01,
26
+ f as boundAlpha,
27
+ u as clamp01,
28
+ s as convertToPercentage,
29
+ i as isOnePointZero,
30
+ n as isPercentage,
31
+ p as pad2
32
+ };
package/tinycolor.js ADDED
@@ -0,0 +1,46 @@
1
+ import { cmykToRgb as e, convertDecimalToHex as t, convertHexToDecimal as a, hslToRgb as n, hsvToRgb as b, numberInputToObject as m, parseIntFromHex as T, rgbToCmyk as i, rgbToHex as g, rgbToHsl as p, rgbToHsv as l, rgbToRgb as s, rgbaToArgbHex as x, rgbaToHex as c } from "./tinycolor/src/conversion.js";
2
+ import { names as f } from "./tinycolor/src/css-color-names.js";
3
+ import { inputToRGB as u, isValidCSSUnit as H, stringInputToObject as y } from "./tinycolor/src/format-input.js";
4
+ import { fromRatio as C, legacyRandom as h } from "./tinycolor/src/from-ratio.js";
5
+ import { TinyColor as O, TinyColor as P } from "./tinycolor/src/index.js";
6
+ import { bounds as k, random as A } from "./tinycolor/src/random.js";
7
+ import { isReadable as F, mostReadable as S, readability as B } from "./tinycolor/src/readability.js";
8
+ import { toMsFilter as M } from "./tinycolor/src/to-ms-filter.js";
9
+ import { bound01 as V, boundAlpha as Z, clamp01 as q, convertToPercentage as w, isOnePointZero as z, isPercentage as E, pad2 as J } from "./tinycolor/src/util.js";
10
+ export {
11
+ O as TinyColor,
12
+ V as bound01,
13
+ Z as boundAlpha,
14
+ k as bounds,
15
+ q as clamp01,
16
+ e as cmykToRgb,
17
+ t as convertDecimalToHex,
18
+ a as convertHexToDecimal,
19
+ w as convertToPercentage,
20
+ P as default,
21
+ C as fromRatio,
22
+ n as hslToRgb,
23
+ b as hsvToRgb,
24
+ u as inputToRGB,
25
+ z as isOnePointZero,
26
+ E as isPercentage,
27
+ F as isReadable,
28
+ H as isValidCSSUnit,
29
+ h as legacyRandom,
30
+ S as mostReadable,
31
+ f as names,
32
+ m as numberInputToObject,
33
+ J as pad2,
34
+ T as parseIntFromHex,
35
+ A as random,
36
+ B as readability,
37
+ i as rgbToCmyk,
38
+ g as rgbToHex,
39
+ p as rgbToHsl,
40
+ l as rgbToHsv,
41
+ s as rgbToRgb,
42
+ x as rgbaToArgbHex,
43
+ c as rgbaToHex,
44
+ y as stringInputToObject,
45
+ M as toMsFilter
46
+ };
package/tree/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { default as I } from "./search/index.js";
1
2
  function a(e, r, f, l = "children") {
2
3
  if (Array.isArray(e) && (e = {
3
4
  [l]: e
@@ -31,7 +32,7 @@ function y(e, r, f, l = "children") {
31
32
  }
32
33
  }
33
34
  const d = a;
34
- function A(e, r, f, l = "children") {
35
+ function h(e, r, f, l = "children") {
35
36
  if (!e) return;
36
37
  const t = Array.isArray(e) ? [...e] : [e];
37
38
  e: for (; t.length; ) {
@@ -50,14 +51,14 @@ function A(e, r, f, l = "children") {
50
51
  t.push(i[u - 1 - n]);
51
52
  }
52
53
  }
53
- function h(e, r) {
54
+ function A(e, r) {
54
55
  return y(e, "id", r);
55
56
  }
56
- function g(e, r, f = !0) {
57
+ function m(e, r, f = !0) {
57
58
  let l = y(e, "value", r)?.label;
58
59
  return !l && f && (l = r), l;
59
60
  }
60
- function m(e, r, f, l = "children") {
61
+ function g(e, r, f, l = "children") {
61
62
  if (!e) return;
62
63
  let t = null;
63
64
  function i(n) {
@@ -77,10 +78,11 @@ function m(e, r, f, l = "children") {
77
78
  export {
78
79
  y as default,
79
80
  a as findNodeBy,
80
- m as getChildWithParentBy,
81
+ g as getChildWithParentBy,
81
82
  y as getItemBy,
82
83
  d as getItemBy2,
83
- A as getItemBy3,
84
- h as getItemByID,
85
- g as getLabelFromDictionaryByValue
84
+ h as getItemBy3,
85
+ A as getItemByID,
86
+ m as getLabelFromDictionaryByValue,
87
+ I as searchTree
86
88
  };
@@ -0,0 +1,90 @@
1
+ import "../../is/index.js";
2
+ import A from "lodash/isArray";
3
+ import z from "lodash/isObjectLike";
4
+ import w from "lodash/isString";
5
+ import T from "lodash/isFunction";
6
+ function v(r, l, a, f) {
7
+ return l && r ? { shouldExit: !0, newMatch: !0 } : a && !r ? { shouldExit: !0, newMatch: !1 } : { shouldExit: !1, newMatch: f || r };
8
+ }
9
+ function q(r, l, a = {}) {
10
+ if (!A(r)) throw new TypeError("参数treeData必须是一个数组");
11
+ if (!z(l)) throw new TypeError("参数searchCondition必须是一个对象");
12
+ const f = {
13
+ strategy: "BFS",
14
+ childrenKey: "children",
15
+ strict: !1,
16
+ fuzzyMatch: !1,
17
+ returnAllMatches: !1,
18
+ caseSensitive: !1,
19
+ allowEmptyString: !1,
20
+ matchMode: "AND",
21
+ ...a
22
+ // 用户配置覆盖默认值
23
+ }, {
24
+ strategy: p,
25
+ childrenKey: S,
26
+ strict: x,
27
+ fuzzyMatch: O,
28
+ returnAllMatches: y,
29
+ caseSensitive: m,
30
+ allowEmptyString: B,
31
+ matchMode: E
32
+ } = f, M = E === "OR", g = E === "AND", h = p === "BFS";
33
+ if (!(h || p === "DFS")) throw new Error('配置 strategy 必须是 "BFS" 或 "DFS"');
34
+ if (!(M || g)) throw new Error('配置 matchMode 必须是 "AND" 或 "OR"');
35
+ if (!w(S)) throw new TypeError("配置 childrenKey 必须是字符串");
36
+ const c = [...r], F = [], D = Object.entries(l);
37
+ if (D.length) {
38
+ const N = (s) => {
39
+ let t = !1;
40
+ for (const [n, e] of D) {
41
+ const i = s[n];
42
+ if (e === "" && !B)
43
+ continue;
44
+ let o = !1;
45
+ try {
46
+ if (e instanceof RegExp)
47
+ o = w(i) ? e.test(i) : !1;
48
+ else if (T(e))
49
+ o = !!e(i);
50
+ else if (O && w(e)) {
51
+ const d = String(i), R = m ? e : e.toLowerCase();
52
+ o = (m ? d : d.toLowerCase()).includes(R);
53
+ } else
54
+ o = x ? i === e : i == e;
55
+ } catch {
56
+ o = !1;
57
+ }
58
+ const u = v(o, M, g, t);
59
+ if (u.shouldExit)
60
+ return u.newMatch;
61
+ t = u.newMatch;
62
+ }
63
+ return t;
64
+ };
65
+ for (; c.length > 0; ) {
66
+ const s = h ? c.shift() : c.pop();
67
+ if (!s) continue;
68
+ try {
69
+ if (N(s))
70
+ if (y)
71
+ F.push(s);
72
+ else
73
+ return s;
74
+ } catch {
75
+ continue;
76
+ }
77
+ const t = s[S];
78
+ if (A(t))
79
+ if (h)
80
+ c.push(...t);
81
+ else
82
+ for (let n = t.length - 1; n >= 0; n--)
83
+ c.push(t[n]);
84
+ }
85
+ }
86
+ return y ? F : null;
87
+ }
88
+ export {
89
+ q as default
90
+ };
package/tree.js CHANGED
@@ -1,11 +1,13 @@
1
- import { getItemBy as y, findNodeBy as B, getChildWithParentBy as g, getItemBy as m, getItemBy2 as a, getItemBy3 as I, getItemByID as i, getLabelFromDictionaryByValue as o } from "./tree/index.js";
1
+ import { default as a } from "./tree/search/index.js";
2
+ import { getItemBy as y, findNodeBy as m, getChildWithParentBy as B, getItemBy as g, getItemBy2 as o, getItemBy3 as I, getItemByID as d, getLabelFromDictionaryByValue as f } from "./tree/index.js";
2
3
  export {
3
4
  y as default,
4
- B as findNodeBy,
5
- g as getChildWithParentBy,
6
- m as getItemBy,
7
- a as getItemBy2,
5
+ m as findNodeBy,
6
+ B as getChildWithParentBy,
7
+ g as getItemBy,
8
+ o as getItemBy2,
8
9
  I as getItemBy3,
9
- i as getItemByID,
10
- o as getLabelFromDictionaryByValue
10
+ d as getItemByID,
11
+ f as getLabelFromDictionaryByValue,
12
+ a as searchTree
11
13
  };
@@ -0,0 +1,4 @@
1
+ export function convertToDurationBasedOnTimeUnits(duration: any, unit: any): string;
2
+ export function dateFormat(date: any, template: any): any;
3
+ export { default as convertTime } from "./convertTime";
4
+ export { dateFormat as dayjsFormat };
@@ -1,24 +1,24 @@
1
- export const ARRAY: "array";
1
+ export const INVALID_NUMBER: "Invalid number";
2
+ export const INVALID_ROUND: "Invalid rounding method";
3
+ export const IEC: "iec";
4
+ export const JEDEC: "jedec";
5
+ export const SI: "si";
2
6
  export const BIT: "bit";
3
7
  export const BITS: "bits";
4
8
  export const BYTE: "byte";
5
9
  export const BYTES: "bytes";
6
- export const EMPTY: "";
7
- export const EXPONENT: "exponent";
10
+ export const SI_KBIT: "kbit";
11
+ export const SI_KBYTE: "kB";
12
+ export const ARRAY: "array";
8
13
  export const FUNCTION: "function";
9
- export const IEC: "iec";
10
- export const INVALID_NUMBER: "Invalid number";
11
- export const INVALID_ROUND: "Invalid rounding method";
12
- export const JEDEC: "jedec";
13
14
  export const OBJECT: "object";
14
- export const PERIOD: ".";
15
+ export const STRING: "string";
16
+ export const EXPONENT: "exponent";
15
17
  export const ROUND: "round";
18
+ export const EMPTY: "";
19
+ export const PERIOD: ".";
16
20
  export const S: "s";
17
- export const SI: "si";
18
- export const SI_KBIT: "kbit";
19
- export const SI_KBYTE: "kB";
20
21
  export const SPACE: " ";
21
- export const STRING: "string";
22
22
  export const ZERO: "0";
23
23
  export namespace STRINGS {
24
24
  namespace symbol {
@@ -1,47 +1,88 @@
1
- export function filesize(arg: any, { bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
1
+ /**
2
+ * Converts a file size in bytes to a human-readable string with appropriate units
3
+ * @param {number|string|bigint} arg - The file size in bytes to convert
4
+ * @param {Object} [options={}] - Configuration options for formatting
5
+ * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes
6
+ * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter
7
+ * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)
8
+ * @param {number} [options.round=2] - Number of decimal places to round to
9
+ * @param {string|boolean} [options.locale=""] - Locale for number formatting, true for system locale
10
+ * @param {Object} [options.localeOptions={}] - Additional options for locale formatting
11
+ * @param {string} [options.separator=""] - Custom decimal separator
12
+ * @param {string} [options.spacer=" "] - String to separate value and unit
13
+ * @param {Object} [options.symbols={}] - Custom unit symbols
14
+ * @param {string} [options.standard=""] - Unit standard to use (SI, IEC, JEDEC)
15
+ * @param {string} [options.output="string"] - Output format: "string", "array", "object", or "exponent"
16
+ * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations
17
+ * @param {Array} [options.fullforms=[]] - Custom full unit names
18
+ * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)
19
+ * @param {string} [options.roundingMethod="round"] - Math rounding method to use
20
+ * @param {number} [options.precision=0] - Number of significant digits (0 for auto)
21
+ * @returns {string|Array|Object|number} Formatted file size based on output option
22
+ * @throws {TypeError} When arg is not a valid number or roundingMethod is invalid
23
+ * @example
24
+ * filesize(1024) // "1 KB"
25
+ * filesize(1024, {bits: true}) // "8 Kb"
26
+ * filesize(1024, {output: "object"}) // {value: 1, symbol: "KB", exponent: 1, unit: "KB"}
27
+ */
28
+ export function filesize(arg: number | string | bigint, { bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
2
29
  bits?: boolean | undefined;
3
30
  pad?: boolean | undefined;
4
31
  base?: number | undefined;
5
32
  round?: number | undefined;
6
- locale?: string | undefined;
7
- localeOptions?: {} | undefined;
33
+ locale?: string | boolean | undefined;
34
+ localeOptions?: Object | undefined;
8
35
  separator?: string | undefined;
9
36
  spacer?: string | undefined;
10
- symbols?: {} | undefined;
37
+ symbols?: Object | undefined;
11
38
  standard?: string | undefined;
12
39
  output?: string | undefined;
13
40
  fullform?: boolean | undefined;
14
- fullforms?: never[] | undefined;
41
+ fullforms?: any[] | undefined;
15
42
  exponent?: number | undefined;
16
43
  roundingMethod?: string | undefined;
17
44
  precision?: number | undefined;
18
- }): string | number | any[] | {
19
- value: any;
20
- symbol: any;
21
- exponent: number;
22
- unit: string;
23
- };
45
+ }): string | any[] | Object | number;
46
+ /**
47
+ * Creates a partially applied version of filesize with preset options
48
+ * @param {Object} [options={}] - Default options to apply to the returned function
49
+ * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes
50
+ * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter
51
+ * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)
52
+ * @param {number} [options.round=2] - Number of decimal places to round to
53
+ * @param {string|boolean} [options.locale=""] - Locale for number formatting, true for system locale
54
+ * @param {Object} [options.localeOptions={}] - Additional options for locale formatting
55
+ * @param {string} [options.separator=""] - Custom decimal separator
56
+ * @param {string} [options.spacer=" "] - String to separate value and unit
57
+ * @param {Object} [options.symbols={}] - Custom unit symbols
58
+ * @param {string} [options.standard=""] - Unit standard to use (SI, IEC, JEDEC)
59
+ * @param {string} [options.output="string"] - Output format: "string", "array", "object", or "exponent"
60
+ * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations
61
+ * @param {Array} [options.fullforms=[]] - Custom full unit names
62
+ * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)
63
+ * @param {string} [options.roundingMethod="round"] - Math rounding method to use
64
+ * @param {number} [options.precision=0] - Number of significant digits (0 for auto)
65
+ * @returns {Function} A function that takes a file size and returns formatted output
66
+ * @example
67
+ * const formatBytes = partial({round: 1, standard: "IEC"});
68
+ * formatBytes(1024) // "1.0 KiB"
69
+ * formatBytes(2048) // "2.0 KiB"
70
+ */
24
71
  export function partial({ bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
25
72
  bits?: boolean | undefined;
26
73
  pad?: boolean | undefined;
27
74
  base?: number | undefined;
28
75
  round?: number | undefined;
29
- locale?: string | undefined;
30
- localeOptions?: {} | undefined;
76
+ locale?: string | boolean | undefined;
77
+ localeOptions?: Object | undefined;
31
78
  separator?: string | undefined;
32
79
  spacer?: string | undefined;
33
- symbols?: {} | undefined;
80
+ symbols?: Object | undefined;
34
81
  standard?: string | undefined;
35
82
  output?: string | undefined;
36
83
  fullform?: boolean | undefined;
37
- fullforms?: never[] | undefined;
84
+ fullforms?: any[] | undefined;
38
85
  exponent?: number | undefined;
39
86
  roundingMethod?: string | undefined;
40
87
  precision?: number | undefined;
41
- }): (arg: any) => string | number | any[] | {
42
- value: any;
43
- symbol: any;
44
- exponent: number;
45
- unit: string;
46
- };
47
- export default filesize;
88
+ }): Function;