@cloudcome/utils-core 1.1.1 → 1.2.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 (291) hide show
  1. package/dist/array.cjs +129 -0
  2. package/dist/array.cjs.map +1 -0
  3. package/dist/array.d.ts +171 -0
  4. package/dist/array.mjs +129 -0
  5. package/dist/array.mjs.map +1 -0
  6. package/dist/async.cjs +219 -0
  7. package/dist/async.cjs.map +1 -0
  8. package/dist/async.d.ts +137 -0
  9. package/dist/async.mjs +219 -0
  10. package/dist/async.mjs.map +1 -0
  11. package/dist/base64.cjs +16 -0
  12. package/dist/base64.cjs.map +1 -0
  13. package/dist/base64.d.ts +7 -0
  14. package/dist/base64.mjs +16 -0
  15. package/dist/base64.mjs.map +1 -0
  16. package/dist/cache.cjs +79 -0
  17. package/dist/cache.cjs.map +1 -0
  18. package/dist/cache.d.ts +90 -0
  19. package/dist/cache.mjs +79 -0
  20. package/dist/cache.mjs.map +1 -0
  21. package/{src/color/contrast.ts → dist/color/contrast.d.ts} +2 -12
  22. package/dist/color/distance.d.ts +8 -0
  23. package/dist/color/helpers.d.ts +2 -0
  24. package/dist/color/hex-hsl.d.ts +3 -0
  25. package/{src/color/hex-hsv.ts → dist/color/hex-hsv.d.ts} +3 -11
  26. package/{src/color/hex-hwb.ts → dist/color/hex-hwb.d.ts} +3 -11
  27. package/dist/color/hex-rgb.d.ts +18 -0
  28. package/{src/color/hsl-lighten.ts → dist/color/hsl-lighten.d.ts} +2 -7
  29. package/{src/color/hsv-brighten.ts → dist/color/hsv-brighten.d.ts} +2 -7
  30. package/{src/color/luminance.ts → dist/color/luminance.d.ts} +2 -9
  31. package/{src/color/mix.ts → dist/color/mix.d.ts} +2 -10
  32. package/dist/color/rgb-hsl.d.ts +23 -0
  33. package/{src/color/rgb-hsv.ts → dist/color/rgb-hsv.d.ts} +3 -30
  34. package/dist/color/rgb-hwb.d.ts +29 -0
  35. package/{src/color/rgb-lab.ts → dist/color/rgb-lab.d.ts} +3 -11
  36. package/dist/color/rgb-whiter.d.ts +12 -0
  37. package/dist/color/rgb-xyz.d.ts +22 -0
  38. package/{src/color/types.ts → dist/color/types.d.ts} +30 -12
  39. package/{src/color/xyz-lab.ts → dist/color/xyz-lab.d.ts} +3 -32
  40. package/dist/color.cjs +250 -0
  41. package/dist/color.cjs.map +1 -0
  42. package/dist/color.mjs +250 -0
  43. package/dist/color.mjs.map +1 -0
  44. package/dist/const.cjs +14 -0
  45. package/dist/const.cjs.map +1 -0
  46. package/dist/const.mjs +15 -0
  47. package/dist/const.mjs.map +1 -0
  48. package/dist/core.cjs +250 -0
  49. package/dist/core.cjs.map +1 -0
  50. package/dist/core.mjs +251 -0
  51. package/dist/core.mjs.map +1 -0
  52. package/dist/crypto/md5.d.mts +1 -0
  53. package/dist/crypto/sha1.d.mts +1 -0
  54. package/dist/crypto/sha256.d.mts +1 -0
  55. package/dist/crypto/sha512.d.mts +1 -0
  56. package/dist/crypto.cjs +812 -0
  57. package/dist/crypto.cjs.map +1 -0
  58. package/{src/crypto.ts → dist/crypto.d.ts} +4 -20
  59. package/dist/crypto.mjs +812 -0
  60. package/dist/crypto.mjs.map +1 -0
  61. package/dist/date/const.d.ts +6 -0
  62. package/dist/date/core.d.ts +52 -0
  63. package/dist/date/days.d.ts +23 -0
  64. package/{src/date/is.ts → dist/date/is.d.ts} +8 -102
  65. package/dist/date/relative.d.ts +44 -0
  66. package/dist/date/start-end.d.ts +73 -0
  67. package/dist/date/timezone.d.ts +67 -0
  68. package/dist/date/weeks.d.ts +72 -0
  69. package/dist/date.cjs +239 -0
  70. package/dist/date.cjs.map +1 -0
  71. package/dist/date.mjs +241 -0
  72. package/dist/date.mjs.map +1 -0
  73. package/dist/dict.cjs +2 -0
  74. package/dist/dict.cjs.map +1 -0
  75. package/dist/dict.mjs +2 -0
  76. package/dist/dict.mjs.map +1 -0
  77. package/dist/each.cjs +18 -0
  78. package/dist/each.cjs.map +1 -0
  79. package/dist/each.mjs +19 -0
  80. package/dist/each.mjs.map +1 -0
  81. package/dist/easing.cjs +151 -0
  82. package/dist/easing.cjs.map +1 -0
  83. package/dist/easing.d.ts +46 -0
  84. package/dist/easing.mjs +151 -0
  85. package/dist/easing.mjs.map +1 -0
  86. package/dist/emitter.cjs +94 -0
  87. package/dist/emitter.cjs.map +1 -0
  88. package/dist/emitter.d.ts +68 -0
  89. package/dist/emitter.mjs +94 -0
  90. package/dist/emitter.mjs.map +1 -0
  91. package/dist/enum.cjs +58 -0
  92. package/dist/enum.cjs.map +1 -0
  93. package/dist/enum.d.ts +68 -0
  94. package/dist/enum.mjs +58 -0
  95. package/dist/enum.mjs.map +1 -0
  96. package/dist/env.cjs +28 -0
  97. package/dist/env.cjs.map +1 -0
  98. package/{src/env.ts → dist/env.d.ts} +6 -30
  99. package/dist/env.mjs +28 -0
  100. package/dist/env.mjs.map +1 -0
  101. package/dist/error.cjs +12 -0
  102. package/dist/error.cjs.map +1 -0
  103. package/{src/error.ts → dist/error.d.ts} +3 -12
  104. package/dist/error.mjs +12 -0
  105. package/dist/error.mjs.map +1 -0
  106. package/dist/exception.cjs +22 -0
  107. package/dist/exception.cjs.map +1 -0
  108. package/dist/exception.d.ts +31 -0
  109. package/dist/exception.mjs +22 -0
  110. package/dist/exception.mjs.map +1 -0
  111. package/dist/fn.cjs +76 -0
  112. package/dist/fn.cjs.map +1 -0
  113. package/dist/fn.d.ts +102 -0
  114. package/dist/fn.mjs +76 -0
  115. package/dist/fn.mjs.map +1 -0
  116. package/dist/index.cjs +5 -0
  117. package/dist/index.cjs.map +1 -0
  118. package/dist/index.d.ts +1 -0
  119. package/dist/index.mjs +5 -0
  120. package/dist/index.mjs.map +1 -0
  121. package/dist/merge.cjs +87 -0
  122. package/dist/merge.cjs.map +1 -0
  123. package/dist/merge.mjs +88 -0
  124. package/dist/merge.mjs.map +1 -0
  125. package/dist/number.cjs +14 -0
  126. package/dist/number.cjs.map +1 -0
  127. package/dist/number.d.ts +153 -0
  128. package/dist/number.mjs +14 -0
  129. package/dist/number.mjs.map +1 -0
  130. package/{src/object/each.ts → dist/object/each.d.ts} +3 -23
  131. package/dist/object/get-set.d.ts +111 -0
  132. package/dist/object/is.d.ts +32 -0
  133. package/dist/object/merge.d.ts +72 -0
  134. package/{src/object/process.ts → dist/object/process.d.ts} +4 -38
  135. package/dist/object.cjs +130 -0
  136. package/dist/object.cjs.map +1 -0
  137. package/dist/object.mjs +130 -0
  138. package/dist/object.mjs.map +1 -0
  139. package/dist/path.cjs +77 -0
  140. package/dist/path.cjs.map +1 -0
  141. package/dist/path.d.ts +82 -0
  142. package/dist/path.mjs +77 -0
  143. package/dist/path.mjs.map +1 -0
  144. package/dist/promise.cjs +62 -0
  145. package/dist/promise.cjs.map +1 -0
  146. package/{src/promise.ts → dist/promise.d.ts} +6 -67
  147. package/dist/promise.mjs +62 -0
  148. package/dist/promise.mjs.map +1 -0
  149. package/dist/qs.cjs +47 -0
  150. package/dist/qs.cjs.map +1 -0
  151. package/{src/qs.ts → dist/qs.d.ts} +3 -60
  152. package/dist/qs.mjs +47 -0
  153. package/dist/qs.mjs.map +1 -0
  154. package/dist/regexp.cjs +66 -0
  155. package/dist/regexp.cjs.map +1 -0
  156. package/dist/regexp.d.ts +65 -0
  157. package/dist/regexp.mjs +66 -0
  158. package/dist/regexp.mjs.map +1 -0
  159. package/dist/string.cjs +16 -0
  160. package/dist/string.cjs.map +1 -0
  161. package/dist/string.d.ts +80 -0
  162. package/dist/string.mjs +16 -0
  163. package/dist/string.mjs.map +1 -0
  164. package/dist/string2.cjs +157 -0
  165. package/dist/string2.cjs.map +1 -0
  166. package/dist/string2.mjs +158 -0
  167. package/dist/string2.mjs.map +1 -0
  168. package/dist/time/from.d.ts +14 -0
  169. package/dist/time/to.d.ts +38 -0
  170. package/dist/time.cjs +82 -0
  171. package/dist/time.cjs.map +1 -0
  172. package/dist/time.mjs +82 -0
  173. package/dist/time.mjs.map +1 -0
  174. package/dist/timer.cjs +119 -0
  175. package/dist/timer.cjs.map +1 -0
  176. package/dist/timer.d.ts +96 -0
  177. package/{src/timer.ts → dist/timer.mjs} +17 -124
  178. package/dist/timer.mjs.map +1 -0
  179. package/dist/tree.cjs +125 -0
  180. package/dist/tree.cjs.map +1 -0
  181. package/{src/tree.ts → dist/tree.d.ts} +41 -225
  182. package/dist/tree.mjs +125 -0
  183. package/dist/tree.mjs.map +1 -0
  184. package/dist/type.cjs +78 -0
  185. package/dist/type.cjs.map +1 -0
  186. package/{src/type.ts → dist/type.d.ts} +20 -96
  187. package/dist/type.mjs +78 -0
  188. package/dist/type.mjs.map +1 -0
  189. package/dist/types.cjs +2 -0
  190. package/dist/types.cjs.map +1 -0
  191. package/{src/types.ts → dist/types.d.ts} +12 -33
  192. package/dist/types.mjs +2 -0
  193. package/dist/types.mjs.map +1 -0
  194. package/dist/unique.cjs +46 -0
  195. package/dist/unique.cjs.map +1 -0
  196. package/dist/unique.d.ts +22 -0
  197. package/dist/unique.mjs +46 -0
  198. package/dist/unique.mjs.map +1 -0
  199. package/dist/url.cjs +37 -0
  200. package/dist/url.cjs.map +1 -0
  201. package/dist/url.d.ts +53 -0
  202. package/dist/url.mjs +37 -0
  203. package/dist/url.mjs.map +1 -0
  204. package/dist/version.cjs +33 -0
  205. package/dist/version.cjs.map +1 -0
  206. package/dist/version.d.ts +32 -0
  207. package/dist/version.mjs +33 -0
  208. package/dist/version.mjs.map +1 -0
  209. package/package.json +8 -2
  210. package/CHANGELOG.md +0 -52
  211. package/src/array.ts +0 -312
  212. package/src/async.ts +0 -379
  213. package/src/base64.ts +0 -20
  214. package/src/cache.ts +0 -146
  215. package/src/color/distance.ts +0 -28
  216. package/src/color/helpers.ts +0 -23
  217. package/src/color/hex-hsl.ts +0 -11
  218. package/src/color/hex-rgb.ts +0 -39
  219. package/src/color/rgb-hsl.ts +0 -53
  220. package/src/color/rgb-hwb.ts +0 -56
  221. package/src/color/rgb-whiter.ts +0 -22
  222. package/src/color/rgb-xyz.ts +0 -62
  223. package/src/crypto/md5.mjs +0 -357
  224. package/src/crypto/sha1.mjs +0 -300
  225. package/src/crypto/sha256.mjs +0 -310
  226. package/src/crypto/sha512.mjs +0 -459
  227. package/src/date/const.ts +0 -6
  228. package/src/date/core.ts +0 -162
  229. package/src/date/days.ts +0 -51
  230. package/src/date/relative.ts +0 -92
  231. package/src/date/start-end.ts +0 -246
  232. package/src/date/timezone.ts +0 -220
  233. package/src/date/weeks.ts +0 -100
  234. package/src/dts/global.d.ts +0 -27
  235. package/src/easing.ts +0 -166
  236. package/src/emitter.ts +0 -117
  237. package/src/enum.ts +0 -171
  238. package/src/exception.ts +0 -68
  239. package/src/fn.ts +0 -197
  240. package/src/index.ts +0 -1
  241. package/src/number.ts +0 -236
  242. package/src/object/get-set.ts +0 -273
  243. package/src/object/is.ts +0 -128
  244. package/src/object/merge.ts +0 -180
  245. package/src/path.ts +0 -188
  246. package/src/regexp.ts +0 -156
  247. package/src/string.ts +0 -146
  248. package/src/time/from.ts +0 -57
  249. package/src/time/to.ts +0 -106
  250. package/src/unique.ts +0 -77
  251. package/src/url.ts +0 -93
  252. package/src/version.ts +0 -71
  253. package/test/array.test.ts +0 -332
  254. package/test/async-real.test.ts +0 -39
  255. package/test/async.test.ts +0 -375
  256. package/test/base64.test.ts +0 -32
  257. package/test/cache.test.ts +0 -83
  258. package/test/color.test.ts +0 -163
  259. package/test/crypto.test.ts +0 -34
  260. package/test/date-tz.test.ts +0 -206
  261. package/test/date.test.ts +0 -353
  262. package/test/easing.test.ts +0 -33
  263. package/test/emitter.test.ts +0 -71
  264. package/test/enum.test.ts +0 -113
  265. package/test/env.test.ts +0 -69
  266. package/test/error.test.ts +0 -58
  267. package/test/exception.test.ts +0 -43
  268. package/test/fn.test.ts +0 -263
  269. package/test/helpers.ts +0 -23
  270. package/test/index.test.ts +0 -6
  271. package/test/number.test.ts +0 -213
  272. package/test/object.test.ts +0 -309
  273. package/test/path.test.ts +0 -156
  274. package/test/promise.test.ts +0 -199
  275. package/test/qs.test.ts +0 -79
  276. package/test/regexp.test.ts +0 -97
  277. package/test/string.test.ts +0 -150
  278. package/test/time.test.ts +0 -214
  279. package/test/timer.test.ts +0 -114
  280. package/test/tree.test.ts +0 -348
  281. package/test/type.test.ts +0 -226
  282. package/test/unique.test.ts +0 -71
  283. package/test/url.test.ts +0 -136
  284. package/test/version.test.ts +0 -52
  285. package/tsconfig.json +0 -31
  286. package/vite.config.mts +0 -114
  287. /package/{src/color.ts → dist/color.d.ts} +0 -0
  288. /package/{src/date.ts → dist/date.d.ts} +0 -0
  289. /package/{src/dict.ts → dist/dict.d.ts} +0 -0
  290. /package/{src/object.ts → dist/object.d.ts} +0 -0
  291. /package/{src/time.ts → dist/time.d.ts} +0 -0
package/dist/url.mjs ADDED
@@ -0,0 +1,37 @@
1
+ function urlParse(url) {
2
+ let result = null;
3
+ try {
4
+ result = new globalThis.URL(url);
5
+ } catch (e) {
6
+ }
7
+ const protocol = (result == null ? void 0 : result.protocol) || "";
8
+ const host = (result == null ? void 0 : result.host) || "";
9
+ return {
10
+ protocol,
11
+ host,
12
+ hostname: (result == null ? void 0 : result.hostname) || "",
13
+ port: (result == null ? void 0 : result.port) || "",
14
+ pathname: (result == null ? void 0 : result.pathname) || "",
15
+ search: (result == null ? void 0 : result.search) || "",
16
+ hash: (result == null ? void 0 : result.hash) || "",
17
+ username: (result == null ? void 0 : result.username) || "",
18
+ password: (result == null ? void 0 : result.password) || ""
19
+ };
20
+ }
21
+ function urlStringify(url) {
22
+ const { protocol, hostname, port, pathname, search, hash, username, password } = url;
23
+ return [
24
+ protocol ? `${protocol}//` : "",
25
+ username && password ? `${username}:${password}@` : "",
26
+ hostname,
27
+ port ? `:${port}` : "",
28
+ pathname,
29
+ search,
30
+ hash
31
+ ].filter(Boolean).join("");
32
+ }
33
+ export {
34
+ urlParse,
35
+ urlStringify
36
+ };
37
+ //# sourceMappingURL=url.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.mjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * 表示解析后的 URL 组件。\n */\nexport type TURLMeta = {\n /**\n * 协议部分,包含冒号,例如 \"https:\"。\n */\n protocol: string;\n /**\n * 主机部分,包括主机名和端口。\n */\n host: string;\n /**\n * 主机名部分。\n */\n hostname: string;\n /**\n * 端口部分。\n */\n port: string;\n /**\n * 路径部分。\n */\n pathname: string;\n /**\n * 查询字符串部分。\n */\n search: string;\n /**\n * 哈希部分。\n */\n hash: string;\n /**\n * 用户名部分。\n */\n username: string;\n /**\n * 密码部分。\n */\n password: string;\n};\n\n/**\n * 解析 URL 字符串为组件对象。\n * @param url - 需要解析的 URL 字符串。\n * @returns 包含解析后 URL 组件的对象。\n */\nexport function urlParse(url: string): TURLMeta {\n let result: URL | null = null;\n\n try {\n // 添加 globalThis 是便于对接外部环境 URL 的自行实现\n // 例如在 uni-app、微信小程序等运行环境。\n result = new globalThis.URL(url);\n } catch (e) {\n // ignore\n }\n\n const protocol = result?.protocol || '';\n const host = result?.host || '';\n\n return {\n protocol,\n host,\n hostname: result?.hostname || '',\n port: result?.port || '',\n pathname: result?.pathname || '',\n search: result?.search || '',\n hash: result?.hash || '',\n username: result?.username || '',\n password: result?.password || '',\n };\n}\n\n/**\n * 将 URLInfo 对象转换回 URL 字符串。\n * @param url - 需要转换的 URLInfo 对象。\n * @returns 转换后的 URL 字符串。\n */\nexport function urlStringify(url: TURLMeta) {\n const { protocol, hostname, port, pathname, search, hash, username, password } = url;\n return [\n protocol ? `${protocol}//` : '',\n username && password ? `${username}:${password}@` : '',\n hostname,\n port ? `:${port}` : '',\n pathname,\n search,\n hash,\n ]\n .filter(Boolean)\n .join('');\n}\n"],"names":[],"mappings":"AA+CO,SAAS,SAAS,KAAuB;AAC9C,MAAI,SAAqB;AAErB,MAAA;AAGO,aAAA,IAAI,WAAW,IAAI,GAAG;AAAA,WACxB,GAAG;AAAA,EAAA;AAIN,QAAA,YAAW,iCAAQ,aAAY;AAC/B,QAAA,QAAO,iCAAQ,SAAQ;AAEtB,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAU,iCAAQ,aAAY;AAAA,IAC9B,OAAM,iCAAQ,SAAQ;AAAA,IACtB,WAAU,iCAAQ,aAAY;AAAA,IAC9B,SAAQ,iCAAQ,WAAU;AAAA,IAC1B,OAAM,iCAAQ,SAAQ;AAAA,IACtB,WAAU,iCAAQ,aAAY;AAAA,IAC9B,WAAU,iCAAQ,aAAY;AAAA,EAChC;AACF;AAOO,SAAS,aAAa,KAAe;AACpC,QAAA,EAAE,UAAU,UAAU,MAAM,UAAU,QAAQ,MAAM,UAAU,SAAA,IAAa;AAC1E,SAAA;AAAA,IACL,WAAW,GAAG,QAAQ,OAAO;AAAA,IAC7B,YAAY,WAAW,GAAG,QAAQ,IAAI,QAAQ,MAAM;AAAA,IACpD;AAAA,IACA,OAAO,IAAI,IAAI,KAAK;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EAEC,EAAA,OAAO,OAAO,EACd,KAAK,EAAE;AACZ;"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const type = require("./type.cjs");
4
+ function internal_numerical(n) {
5
+ return Number.isNaN(n) || type.isUndefined(n) ? 0 : n;
6
+ }
7
+ function versionParse(version) {
8
+ const [major, minor, patch] = version.split(".").map(Number);
9
+ return {
10
+ major: internal_numerical(major),
11
+ minor: internal_numerical(minor),
12
+ patch: internal_numerical(patch)
13
+ };
14
+ }
15
+ function versionCompare(version1, version2) {
16
+ const vo1 = versionParse(version1);
17
+ const vo2 = versionParse(version2);
18
+ const order = ["major", "minor", "patch"];
19
+ for (const key of order) {
20
+ const n1 = vo1[key];
21
+ const n2 = vo2[key];
22
+ if (n1 > n2) {
23
+ return 1;
24
+ }
25
+ if (n1 < n2) {
26
+ return -1;
27
+ }
28
+ }
29
+ return 0;
30
+ }
31
+ exports.versionCompare = versionCompare;
32
+ exports.versionParse = versionParse;
33
+ //# sourceMappingURL=version.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.cjs","sources":["../src/version.ts"],"sourcesContent":["import { isUndefined } from './type';\n\n/**\n * 表示包含主版本号、次版本号和修订号的对象\n */\nexport type TVersionObject = {\n /**\n * 主版本号,当有不兼容的API修改时递增\n */\n major: number;\n /**\n * 次版本号,当有向下兼容的功能新增时递增\n */\n minor: number;\n /**\n * 修订号,当有向下兼容的问题修正时递增\n */\n patch: number;\n};\n\n/**\n * 将数字转换为安全的数值,如果输入为NaN则返回0\n * @param n - 要转换的数字\n * @returns 安全的数字(如果输入为NaN则返回0)\n */\nfunction internal_numerical(n?: number) {\n return Number.isNaN(n) || isUndefined(n) ? 0 : n;\n}\n\n/**\n * 将语义化版本号字符串解析为VersionObject对象\n * @param version - 要解析的版本号字符串 (例如 \"1.2.3\")\n * @returns 包含主版本号、次版本号和修订号的对象\n * @throws 如果版本号字符串格式无效将抛出错误\n */\nexport function versionParse(version: string): TVersionObject {\n const [major, minor, patch] = version.split('.').map(Number);\n return {\n major: internal_numerical(major),\n minor: internal_numerical(minor),\n patch: internal_numerical(patch),\n };\n}\n\n/**\n * 比较两个语义化版本号字符串\n * @param version1 - 要比较的第一个版本号字符串\n * @param version2 - 要比较的第二个版本号字符串\n * @returns 如果version1较大返回1,version2较大返回-1,相等返回0\n * @throws 如果任一版本号字符串格式无效将抛出错误\n */\nexport function versionCompare(version1: string, version2: string): number {\n const vo1 = versionParse(version1);\n const vo2 = versionParse(version2);\n const order: (keyof TVersionObject)[] = ['major', 'minor', 'patch'];\n\n for (const key of order) {\n const n1 = vo1[key];\n const n2 = vo2[key];\n\n if (n1 > n2) {\n return 1;\n }\n\n if (n1 < n2) {\n return -1;\n }\n }\n\n return 0;\n}\n"],"names":["isUndefined"],"mappings":";;;AAyBA,SAAS,mBAAmB,GAAY;AACtC,SAAO,OAAO,MAAM,CAAC,KAAKA,KAAAA,YAAY,CAAC,IAAI,IAAI;AACjD;AAQO,SAAS,aAAa,SAAiC;AACtD,QAAA,CAAC,OAAO,OAAO,KAAK,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI,MAAM;AACpD,SAAA;AAAA,IACL,OAAO,mBAAmB,KAAK;AAAA,IAC/B,OAAO,mBAAmB,KAAK;AAAA,IAC/B,OAAO,mBAAmB,KAAK;AAAA,EACjC;AACF;AASgB,SAAA,eAAe,UAAkB,UAA0B;AACnE,QAAA,MAAM,aAAa,QAAQ;AAC3B,QAAA,MAAM,aAAa,QAAQ;AACjC,QAAM,QAAkC,CAAC,SAAS,SAAS,OAAO;AAElE,aAAW,OAAO,OAAO;AACjB,UAAA,KAAK,IAAI,GAAG;AACZ,UAAA,KAAK,IAAI,GAAG;AAElB,QAAI,KAAK,IAAI;AACJ,aAAA;AAAA,IAAA;AAGT,QAAI,KAAK,IAAI;AACJ,aAAA;AAAA,IAAA;AAAA,EACT;AAGK,SAAA;AACT;;;"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 表示包含主版本号、次版本号和修订号的对象
3
+ */
4
+ export type TVersionObject = {
5
+ /**
6
+ * 主版本号,当有不兼容的API修改时递增
7
+ */
8
+ major: number;
9
+ /**
10
+ * 次版本号,当有向下兼容的功能新增时递增
11
+ */
12
+ minor: number;
13
+ /**
14
+ * 修订号,当有向下兼容的问题修正时递增
15
+ */
16
+ patch: number;
17
+ };
18
+ /**
19
+ * 将语义化版本号字符串解析为VersionObject对象
20
+ * @param version - 要解析的版本号字符串 (例如 "1.2.3")
21
+ * @returns 包含主版本号、次版本号和修订号的对象
22
+ * @throws 如果版本号字符串格式无效将抛出错误
23
+ */
24
+ export declare function versionParse(version: string): TVersionObject;
25
+ /**
26
+ * 比较两个语义化版本号字符串
27
+ * @param version1 - 要比较的第一个版本号字符串
28
+ * @param version2 - 要比较的第二个版本号字符串
29
+ * @returns 如果version1较大返回1,version2较大返回-1,相等返回0
30
+ * @throws 如果任一版本号字符串格式无效将抛出错误
31
+ */
32
+ export declare function versionCompare(version1: string, version2: string): number;
@@ -0,0 +1,33 @@
1
+ import { isUndefined } from "./type.mjs";
2
+ function internal_numerical(n) {
3
+ return Number.isNaN(n) || isUndefined(n) ? 0 : n;
4
+ }
5
+ function versionParse(version) {
6
+ const [major, minor, patch] = version.split(".").map(Number);
7
+ return {
8
+ major: internal_numerical(major),
9
+ minor: internal_numerical(minor),
10
+ patch: internal_numerical(patch)
11
+ };
12
+ }
13
+ function versionCompare(version1, version2) {
14
+ const vo1 = versionParse(version1);
15
+ const vo2 = versionParse(version2);
16
+ const order = ["major", "minor", "patch"];
17
+ for (const key of order) {
18
+ const n1 = vo1[key];
19
+ const n2 = vo2[key];
20
+ if (n1 > n2) {
21
+ return 1;
22
+ }
23
+ if (n1 < n2) {
24
+ return -1;
25
+ }
26
+ }
27
+ return 0;
28
+ }
29
+ export {
30
+ versionCompare,
31
+ versionParse
32
+ };
33
+ //# sourceMappingURL=version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.mjs","sources":["../src/version.ts"],"sourcesContent":["import { isUndefined } from './type';\n\n/**\n * 表示包含主版本号、次版本号和修订号的对象\n */\nexport type TVersionObject = {\n /**\n * 主版本号,当有不兼容的API修改时递增\n */\n major: number;\n /**\n * 次版本号,当有向下兼容的功能新增时递增\n */\n minor: number;\n /**\n * 修订号,当有向下兼容的问题修正时递增\n */\n patch: number;\n};\n\n/**\n * 将数字转换为安全的数值,如果输入为NaN则返回0\n * @param n - 要转换的数字\n * @returns 安全的数字(如果输入为NaN则返回0)\n */\nfunction internal_numerical(n?: number) {\n return Number.isNaN(n) || isUndefined(n) ? 0 : n;\n}\n\n/**\n * 将语义化版本号字符串解析为VersionObject对象\n * @param version - 要解析的版本号字符串 (例如 \"1.2.3\")\n * @returns 包含主版本号、次版本号和修订号的对象\n * @throws 如果版本号字符串格式无效将抛出错误\n */\nexport function versionParse(version: string): TVersionObject {\n const [major, minor, patch] = version.split('.').map(Number);\n return {\n major: internal_numerical(major),\n minor: internal_numerical(minor),\n patch: internal_numerical(patch),\n };\n}\n\n/**\n * 比较两个语义化版本号字符串\n * @param version1 - 要比较的第一个版本号字符串\n * @param version2 - 要比较的第二个版本号字符串\n * @returns 如果version1较大返回1,version2较大返回-1,相等返回0\n * @throws 如果任一版本号字符串格式无效将抛出错误\n */\nexport function versionCompare(version1: string, version2: string): number {\n const vo1 = versionParse(version1);\n const vo2 = versionParse(version2);\n const order: (keyof TVersionObject)[] = ['major', 'minor', 'patch'];\n\n for (const key of order) {\n const n1 = vo1[key];\n const n2 = vo2[key];\n\n if (n1 > n2) {\n return 1;\n }\n\n if (n1 < n2) {\n return -1;\n }\n }\n\n return 0;\n}\n"],"names":[],"mappings":";AAyBA,SAAS,mBAAmB,GAAY;AACtC,SAAO,OAAO,MAAM,CAAC,KAAK,YAAY,CAAC,IAAI,IAAI;AACjD;AAQO,SAAS,aAAa,SAAiC;AACtD,QAAA,CAAC,OAAO,OAAO,KAAK,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI,MAAM;AACpD,SAAA;AAAA,IACL,OAAO,mBAAmB,KAAK;AAAA,IAC/B,OAAO,mBAAmB,KAAK;AAAA,IAC/B,OAAO,mBAAmB,KAAK;AAAA,EACjC;AACF;AASgB,SAAA,eAAe,UAAkB,UAA0B;AACnE,QAAA,MAAM,aAAa,QAAQ;AAC3B,QAAA,MAAM,aAAa,QAAQ;AACjC,QAAM,QAAkC,CAAC,SAAS,SAAS,OAAO;AAElE,aAAW,OAAO,OAAO;AACjB,UAAA,KAAK,IAAI,GAAG;AACZ,UAAA,KAAK,IAAI,GAAG;AAElB,QAAI,KAAK,IAAI;AACJ,aAAA;AAAA,IAAA;AAGT,QAAI,KAAK,IAAI;AACJ,aAAA;AAAA,IAAA;AAAA,EACT;AAGK,SAAA;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcome/utils-core",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "cloudcome core utils",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -262,7 +262,13 @@
262
262
  "main": "./dist/index.cjs",
263
263
  "module": "./dist/index.mjs",
264
264
  "types": "./dist/index.d.ts",
265
- "repository": "https://github.com/cloudcome/utils",
265
+ "files": [
266
+ "dist"
267
+ ],
268
+ "repository": {
269
+ "type": "git",
270
+ "url": "git+https://github.com/cloudcome/utils.git"
271
+ },
266
272
  "keywords": [
267
273
  "utils",
268
274
  "cloudcome",
package/CHANGELOG.md DELETED
@@ -1,52 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [1.1.1](https://github.com/cloudcome/utils/compare/@cloudcome/utils-core@1.1.0...@cloudcome/utils-core@1.1.1) (2025-08-30)
7
-
8
- **Note:** Version bump only for package @cloudcome/utils-core
9
-
10
- # 1.1.0 (2025-08-27)
11
-
12
- ### Bug Fixes
13
-
14
- * **utils-core:** 修复 asyncShared 函数的错误处理和类型定义问题 ([27264d2](https://github.com/cloudcome/utils/commit/27264d2b8dc154ca83f0c2becd95ef44c12ec1a6))
15
- * **utils-core:** 修复 pathRelativize 函数对相对路径的处理 ([f632c9b](https://github.com/cloudcome/utils/commit/f632c9b56e22914958ded53238caf2db9e2c73a8))
16
- * **utils-core:** 修复 qsParse 函数查询字符串解析问题 ([ce273f9](https://github.com/cloudcome/utils/commit/ce273f9a252a506402858bfa3ab72185fae805d4))
17
- * **utils-core:** 修正 numberAbbr 函数的计算逻辑 ([b8483c7](https://github.com/cloudcome/utils/commit/b8483c73218894f3b1eec939f59377f2d9049422))
18
-
19
- ### Features
20
-
21
- * **array:** 添加数组差异对比功能 ([35acf91](https://github.com/cloudcome/utils/commit/35acf916a10fa1395633faccac67b7f70e575f2b))
22
- * **array:** 添加数组差异比较功能 ([4dc5fa7](https://github.com/cloudcome/utils/commit/4dc5fa7a9d5c9e264a2ebb5144bcd9a08656cbed))
23
- * **async:** 为 asyncShared 函数添加回调事件支持 ([af6737f](https://github.com/cloudcome/utils/commit/af6737fbf0e59f694f229fd566fb0e30f9d9c9b1))
24
- * **async:** 添加 asyncShared 函数实现异步函数结果共享 ([5883200](https://github.com/cloudcome/utils/commit/588320034e07fec03f0bdd16a521d9a3c65013fb))
25
- * **cache:** 为缓存添加清除功能并优化测试用例 ([653805e](https://github.com/cloudcome/utils/commit/653805e79965c0c27202b282ac46f486444900fc))
26
- * **core:** 添加枚举定义和工厂函数 ([6a56ab8](https://github.com/cloudcome/utils/commit/6a56ab874412bad5cf18234d59778756b53c7903))
27
- * **date:** 优化时区转换逻辑并添加新功能 ([1852c73](https://github.com/cloudcome/utils/commit/1852c731f80e6c2a4ff524e9638349bbc1235c9e))
28
- * **date:** 增加时区相关功能并优化日期解析 ([993ccfe](https://github.com/cloudcome/utils/commit/993ccfe67fb2979ee9ca6c5c998af6ceca4cf9cd))
29
- * **number:** 增强 numberFixed 函数功能并优化相关测试 ([c94a9ff](https://github.com/cloudcome/utils/commit/c94a9ff97bc2b95a98356d66f6e1d211e0333cf9))
30
- * **number:** 添加数字格式化功能并优化相关测试 ([1b23e94](https://github.com/cloudcome/utils/commit/1b23e94f28772168481cff36ce8287a7986da90f))
31
- * **path:** 添加路径相对化处理函数 ([aaac0a0](https://github.com/cloudcome/utils/commit/aaac0a0b765b4c6cebd7eaa6c6c676fa46b9eb61))
32
- * **time:** 增强时间转换功能并添加新方法 ([dfaf38f](https://github.com/cloudcome/utils/commit/dfaf38f9c41daa58754ec391f5070e016189e2cc))
33
- * **time:** 添加时间字符串转换函数并重命名时间处理函数 ([4a08954](https://github.com/cloudcome/utils/commit/4a08954b278874a0d7c84167da0a727f18548d60))
34
- * **time:** 添加时间格式化相关工具函数 ([2efb2d6](https://github.com/cloudcome/utils/commit/2efb2d6a92b5df0efd6be197d511aefe5e4cd553))
35
- * **types:** 添加 DeepPartial 类型 ([2d551c5](https://github.com/cloudcome/utils/commit/2d551c5745310ea37f8bd6fe169918d99e3fde12))
36
- * **tz:** 重构 TZDate 类并添加时区转换功能 ([434e985](https://github.com/cloudcome/utils/commit/434e985141aa2fbd34c9da1048bb21cd50f9268e))
37
- * **unique:** 增加生成唯一字符串功能 ([287f384](https://github.com/cloudcome/utils/commit/287f384406ea710885b1a68da66ef3dfdddae7f2))
38
- * **utils-core:** 为 TzDate 类添加 getTimezoneOrder 方法 ([23bbaac](https://github.com/cloudcome/utils/commit/23bbaac597222dad99830048712b6c50b9db4f29))
39
- * **utils-core:** 优化 arrayDiff 函数返回值结构 ([0fc18c0](https://github.com/cloudcome/utils/commit/0fc18c0ef72145f348de7085c69b09d73d75b58c))
40
- * **utils-core:** 优化数字工具函数并添加文件大小缩写功能 ([082e070](https://github.com/cloudcome/utils/commit/082e070216bcd74c12d9a2667d6829355c07dcb1))
41
- * **utils-core:** 实现时区相关工具类 TZDate ([22ec027](https://github.com/cloudcome/utils/commit/22ec02770966cf3f6a4758da711d8489fdbcfb20))
42
- * **utils-core:** 新增 base64、error、time 和 unique模块 ([ce90232](https://github.com/cloudcome/utils/commit/ce90232ba0dac56346384b8d6f1f608ee3a3b4b7))
43
- * **utils-core:** 新增错误处理相关工具函数 ([3a9b64a](https://github.com/cloudcome/utils/commit/3a9b64a304c9c055fe60eaf4a97449487110bc9b))
44
- * **utils-core:** 添加 base64 转换为 Blob 的函数 ([f046578](https://github.com/cloudcome/utils/commit/f0465780b6ce7941449a209188a0a8a9b119ceb8))
45
- * **utils-core:** 添加 createMinDelayPromise 函数并编写相关测试 ([a436462](https://github.com/cloudcome/utils/commit/a43646286949a35e51db56e647e2a44c9a1a3b84))
46
- * **utils-core:** 添加 enum 模块并更新相关配置 ([15b5971](https://github.com/cloudcome/utils/commit/15b597149184802a87622d247356e9a5d6731de5))
47
- * **utils-core:** 添加 stringify 函数并优化类型检查 ([4298f04](https://github.com/cloudcome/utils/commit/4298f04665ff0eae9265305334f2d1c2ed38e59b))
48
- * **utils-core:** 添加 uniqueBigInt函数并实现相关测试 ([ae37704](https://github.com/cloudcome/utils/commit/ae377042199b75dd9e971d7231767209b1607352))
49
- * **utils-core:** 添加数组移动函数并优化数组操作 ([461165b](https://github.com/cloudcome/utils/commit/461165b0f7d12395408f3ea92cf5a1d5a4591c19))
50
- * **utils-core:** 添加自定义异常构建函数 ([1b46a3b](https://github.com/cloudcome/utils/commit/1b46a3b0ec3300c69c954049f03c4acd0f75c09d))
51
- * **utils-core:** 重构 AsyncQueue 类 ([8fc8b7b](https://github.com/cloudcome/utils/commit/8fc8b7b7771ca53bad96409ff2a8a714f918b4d5))
52
- * **utils-core:** 重构 qsParse 和 qsStringify 函数 ([9335a3d](https://github.com/cloudcome/utils/commit/9335a3dfa0b5ba501b520b46f2d087fb77114319))
package/src/array.ts DELETED
@@ -1,312 +0,0 @@
1
- import { isArray, isObject } from './type';
2
- import type { MaybePromise } from './types';
3
-
4
- /**
5
- * 检查给定的值是否为类数组对象。
6
- *
7
- * 类数组对象是指具有 `length` 属性且 `length` 属性为非负数的对象。
8
- *
9
- * @param unknown - 要检查的值。
10
- * @returns 如果值是类数组对象,则返回 `true`,否则返回 `false`。
11
- */
12
- export function isArrayLike(unknown: unknown) {
13
- if (isArray(unknown)) return true;
14
-
15
- if (isObject(unknown)) {
16
- const arrayLike = unknown as { length: unknown };
17
- return typeof arrayLike.length === 'number' && arrayLike.length >= 0;
18
- }
19
-
20
- return false;
21
- }
22
-
23
- /**
24
- * 从数组中选择指定索引的元素。
25
- *
26
- * @param array - 要从中选择元素的数组。
27
- * @param indexes - 要选择的元素的索引数组。
28
- * @returns 包含指定索引元素的新数组。
29
- */
30
- export function arrayPick<T>(array: T[], indexes: number[]) {
31
- const indexes2 = [...indexes];
32
- return array.filter((_, i) => {
33
- const index = indexes2.indexOf(i);
34
- if (index === -1) return false;
35
- indexes2.splice(index, 1);
36
- return true;
37
- });
38
- }
39
-
40
- /**
41
- * 从数组中排除指定索引的元素。
42
- *
43
- * @param array - 要从中排除元素的数组。
44
- * @param indexes - 要排除的元素的索引数组。
45
- * @returns 包含排除指定索引元素后的新数组。
46
- */
47
- export function arrayOmit<T>(array: T[], indexes: number[]) {
48
- const indexes2 = [...indexes];
49
- return array.filter((_, i) => {
50
- const index = indexes2.indexOf(i);
51
- if (index === -1) return true;
52
- indexes2.splice(index, 1);
53
- return false;
54
- });
55
- }
56
-
57
- /**
58
- * 遍历数组中的每个元素,并对每个元素执行提供的回调函数。
59
- *
60
- * @param array - 要遍历的数组。
61
- * @param iterator - 对每个元素执行的回调函数。如果回调函数返回 `false`,则提前终止遍历。
62
- * @param reverse - 是否以相反的顺序遍历数组。默认为 `false`。
63
- * @returns 无返回值。
64
- *
65
- * @example
66
- * ```typescript
67
- * const arr = [1, 2, 3];
68
- * arrayEach(arr, (item, index) => {
69
- * console.log(item, index);
70
- * if (index === 1) return false; // 提前终止遍历
71
- * });
72
- * ```
73
- */
74
- export function arrayEach<T>(array: T[], iterator: (item: T, index: number) => false | unknown, reverse = false) {
75
- const _array = [...array];
76
- const length = array.length;
77
-
78
- if (reverse) {
79
- for (let i = length - 1; i >= 0; i--) {
80
- if (iterator(_array[i], i) === false) {
81
- break;
82
- }
83
- }
84
- } else {
85
- for (let i = 0; i < length; i++) {
86
- if (iterator(_array[i], i) === false) {
87
- break;
88
- }
89
- }
90
- }
91
- }
92
-
93
- /**
94
- * 异步遍历数组中的每个元素,并对每个元素执行提供的回调函数。
95
- *
96
- * @param array - 要遍历的数组。
97
- * @param iterator - 对每个元素执行的异步回调函数。如果回调函数返回 `false`,则提前终止遍历。
98
- * @param reverse - 是否以相反的顺序遍历数组。默认为 `false`。
99
- * @returns 无返回值。
100
- *
101
- * @example
102
- * ```typescript
103
- * const arr = [1, 2, 3];
104
- * await arrayEachAsync(arr, async (item, index) => {
105
- * await someAsyncOperation(item);
106
- * if (index === 1) return false; // 提前终止遍历
107
- * });
108
- * ```
109
- */
110
- export async function arrayEachAsync<T>(
111
- array: T[],
112
- iterator: (item: T, index: number) => MaybePromise<false | unknown>,
113
- reverse = false,
114
- ) {
115
- const _array = [...array];
116
- const length = array.length;
117
-
118
- if (reverse) {
119
- for (let i = length - 1; i >= 0; i--) {
120
- if ((await iterator(_array[i], i)) === false) {
121
- break;
122
- }
123
- }
124
- } else {
125
- for (let i = 0; i < length; i++) {
126
- if ((await iterator(_array[i], i)) === false) {
127
- break;
128
- }
129
- }
130
- }
131
- }
132
-
133
- /**
134
- * 将数组中的元素移动到指定位置。
135
- *
136
- * @param array - 要移动元素的数组。
137
- * @param from - 要移动的元素的起始位置。
138
- * @param to - 要移动的元素的目标位置。
139
- * @returns 新的数组,其中包含移动后的元素。
140
- *
141
- * @example
142
- * ```typescript
143
- * const arr = [1, 2, 3, 4, 5];
144
- * const newArr = arrayMove(arr, 1, 3);
145
- * // 返回 [1, 3, 4, 2, 5]
146
- * ```
147
- */
148
- export function arrayMove<T>(array: T[], from: number, to: number) {
149
- const array2 = [...array];
150
-
151
- if (from < 0 || from >= array2.length || to < 0 || to >= array2.length) {
152
- return array2;
153
- }
154
-
155
- const item = array2[from];
156
-
157
- array2.splice(from, 1);
158
- array2.splice(to, 0, item);
159
-
160
- return array2;
161
- }
162
-
163
- /**
164
- * 比较两个数组的差异,返回包含删除、新增和相同元素信息的对象
165
- *
166
- * @template T - 数组元素的类型
167
- * @param {T[]} refArray - 参考数组(原始数组)
168
- * @param {T[]} curArray - 当前数组(比较数组)
169
- * @returns {ArrayDiffs<T>} 包含差异信息的对象
170
- *
171
- * @example
172
- * ```typescript
173
- * const ref = [1, 2, 3];
174
- * const cur = [2, 3, 4];
175
- * const diff = arrayDiff(ref, cur);
176
- * // 返回结果:
177
- * // {
178
- * // deletes: [{refIndexes: [0], refValue: 1}],
179
- * // adds: [{curIndexes: [2], curValue: 4}],
180
- * // equals: [
181
- * // {refIndexes: [1], curIndexes: [0], refValue: 2, curValue: 2},
182
- * // {refIndexes: [2], curIndexes: [1], refValue: 3, curValue: 3}
183
- * // ]
184
- * // }
185
- * ```
186
- */
187
- export type ArrayDiffs<T> = {
188
- /**
189
- * 被删除的元素列表
190
- * @type {Array}
191
- * @property {number[]} refIndexes - 元素在参考数组中的所有索引位置
192
- * @property {T} refValue - 被删除的元素值
193
- */
194
- deletes: {
195
- /**
196
- * 元素在参考数组中的所有索引位置
197
- * @type {number[]}
198
- */
199
- refIndexes: number[];
200
- /**
201
- * 被删除的元素值
202
- * @type {T}
203
- */
204
- refValue: T;
205
- }[];
206
-
207
- /**
208
- * 新增的元素列表
209
- * @type {Array}
210
- * @property {number[]} curIndexes - 元素在当前数组中的所有索引位置
211
- * @property {T} curValue - 新增的元素值
212
- */
213
- adds: {
214
- /**
215
- * 元素在当前数组中的所有索引位置
216
- * @type {number[]}
217
- */
218
- curIndexes: number[];
219
- /**
220
- * 新增的元素值
221
- * @type {T}
222
- */
223
- curValue: T;
224
- }[];
225
-
226
- /**
227
- * 相同的元素列表
228
- * @type {Array}
229
- * @property {number[]} refIndexes - 元素在参考数组中的所有索引位置
230
- * @property {number[]} curIndexes - 元素在当前数组中的所有索引位置
231
- * @property {T} refValue - 参考数组中的元素值
232
- * @property {T} curValue - 当前数组中的元素值
233
- */
234
- equals: {
235
- /**
236
- * 元素在参考数组中的所有索引位置
237
- * @type {number[]}
238
- */
239
- refIndexes: number[];
240
- /**
241
- * 元素在当前数组中的所有索引位置
242
- * @type {number[]}
243
- */
244
- curIndexes: number[];
245
- /**
246
- * 参考数组中的元素值
247
- * @type {T}
248
- */
249
- refValue: T;
250
- /**
251
- * 当前数组中的元素值
252
- * @type {T}
253
- */
254
- curValue: T;
255
- }[];
256
- };
257
-
258
- export function arrayDiff<T>(refArray: T[], curArray: T[]): ArrayDiffs<T> {
259
- const buildMap = (arr: T[]) => {
260
- const map = new Map<T, number[]>();
261
-
262
- arr.forEach((item, index) => {
263
- const indexes = map.get(item) || [];
264
- indexes.push(index);
265
- map.set(item, indexes);
266
- });
267
-
268
- return map;
269
- };
270
- const map1 = buildMap(refArray);
271
- const map2 = buildMap(curArray);
272
- const deletes = new Set<T>();
273
- const adds = new Set<T>();
274
- const equals = new Set<T>();
275
-
276
- for (const key of map1.keys()) {
277
- if (map2.has(key)) {
278
- equals.add(key);
279
- } else {
280
- deletes.add(key);
281
- }
282
- }
283
-
284
- for (const key of map2.keys()) {
285
- if (!map1.has(key)) {
286
- adds.add(key);
287
- }
288
- }
289
-
290
- return {
291
- deletes: [...deletes].map((it) => ({
292
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
293
- refIndexes: map1.get(it)!,
294
- refValue: it,
295
- })),
296
-
297
- adds: [...adds].map((it) => ({
298
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
299
- curIndexes: map2.get(it)!,
300
- curValue: it,
301
- })),
302
-
303
- equals: [...equals].map((it) => ({
304
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
305
- refIndexes: map1.get(it)!,
306
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
307
- curIndexes: map2.get(it)!,
308
- refValue: it,
309
- curValue: it,
310
- })),
311
- };
312
- }