@cloudcome/utils-core 1.1.0 → 1.1.1

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 (292) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +21 -0
  3. package/package.json +279 -1
  4. package/src/array.ts +312 -0
  5. package/src/async.ts +379 -0
  6. package/src/base64.ts +20 -0
  7. package/src/cache.ts +146 -0
  8. package/{dist/color/contrast.d.ts → src/color/contrast.ts} +12 -2
  9. package/src/color/distance.ts +28 -0
  10. package/src/color/helpers.ts +23 -0
  11. package/src/color/hex-hsl.ts +11 -0
  12. package/{dist/color/hex-hsv.d.ts → src/color/hex-hsv.ts} +11 -3
  13. package/{dist/color/hex-hwb.d.ts → src/color/hex-hwb.ts} +11 -3
  14. package/src/color/hex-rgb.ts +39 -0
  15. package/{dist/color/hsl-lighten.d.ts → src/color/hsl-lighten.ts} +7 -2
  16. package/{dist/color/hsv-brighten.d.ts → src/color/hsv-brighten.ts} +7 -2
  17. package/{dist/color/luminance.d.ts → src/color/luminance.ts} +9 -2
  18. package/{dist/color/mix.d.ts → src/color/mix.ts} +10 -2
  19. package/src/color/rgb-hsl.ts +53 -0
  20. package/{dist/color/rgb-hsv.d.ts → src/color/rgb-hsv.ts} +30 -3
  21. package/src/color/rgb-hwb.ts +56 -0
  22. package/{dist/color/rgb-lab.d.ts → src/color/rgb-lab.ts} +11 -3
  23. package/src/color/rgb-whiter.ts +22 -0
  24. package/src/color/rgb-xyz.ts +62 -0
  25. package/{dist/color/types.d.ts → src/color/types.ts} +12 -30
  26. package/{dist/color/xyz-lab.d.ts → src/color/xyz-lab.ts} +32 -3
  27. package/src/crypto/md5.mjs +357 -0
  28. package/src/crypto/sha1.mjs +300 -0
  29. package/src/crypto/sha256.mjs +310 -0
  30. package/src/crypto/sha512.mjs +459 -0
  31. package/{dist/crypto.d.ts → src/crypto.ts} +20 -4
  32. package/src/date/const.ts +6 -0
  33. package/src/date/core.ts +162 -0
  34. package/src/date/days.ts +51 -0
  35. package/{dist/date/is.d.ts → src/date/is.ts} +102 -8
  36. package/src/date/relative.ts +92 -0
  37. package/src/date/start-end.ts +246 -0
  38. package/src/date/timezone.ts +220 -0
  39. package/src/date/weeks.ts +100 -0
  40. package/src/dts/global.d.ts +27 -0
  41. package/src/easing.ts +166 -0
  42. package/src/emitter.ts +117 -0
  43. package/src/enum.ts +171 -0
  44. package/{dist/env.d.ts → src/env.ts} +30 -6
  45. package/{dist/error.d.ts → src/error.ts} +12 -3
  46. package/src/exception.ts +68 -0
  47. package/src/fn.ts +197 -0
  48. package/src/index.ts +1 -0
  49. package/src/number.ts +236 -0
  50. package/{dist/object/each.d.ts → src/object/each.ts} +23 -3
  51. package/src/object/get-set.ts +273 -0
  52. package/src/object/is.ts +128 -0
  53. package/src/object/merge.ts +180 -0
  54. package/{dist/object/process.d.ts → src/object/process.ts} +38 -4
  55. package/src/path.ts +188 -0
  56. package/{dist/promise.d.ts → src/promise.ts} +67 -6
  57. package/{dist/qs.d.ts → src/qs.ts} +60 -3
  58. package/src/regexp.ts +156 -0
  59. package/src/string.ts +146 -0
  60. package/src/time/from.ts +57 -0
  61. package/src/time/to.ts +106 -0
  62. package/{dist/timer.mjs → src/timer.ts} +124 -17
  63. package/{dist/tree.d.ts → src/tree.ts} +225 -41
  64. package/{dist/type.d.ts → src/type.ts} +96 -20
  65. package/{dist/types.d.ts → src/types.ts} +33 -12
  66. package/src/unique.ts +77 -0
  67. package/src/url.ts +93 -0
  68. package/src/version.ts +71 -0
  69. package/test/array.test.ts +332 -0
  70. package/test/async-real.test.ts +39 -0
  71. package/test/async.test.ts +375 -0
  72. package/test/base64.test.ts +32 -0
  73. package/test/cache.test.ts +83 -0
  74. package/test/color.test.ts +163 -0
  75. package/test/crypto.test.ts +34 -0
  76. package/test/date-tz.test.ts +206 -0
  77. package/test/date.test.ts +353 -0
  78. package/test/easing.test.ts +33 -0
  79. package/test/emitter.test.ts +71 -0
  80. package/test/enum.test.ts +113 -0
  81. package/test/env.test.ts +69 -0
  82. package/test/error.test.ts +58 -0
  83. package/test/exception.test.ts +43 -0
  84. package/test/fn.test.ts +263 -0
  85. package/test/helpers.ts +23 -0
  86. package/test/index.test.ts +6 -0
  87. package/test/number.test.ts +213 -0
  88. package/test/object.test.ts +309 -0
  89. package/test/path.test.ts +156 -0
  90. package/test/promise.test.ts +199 -0
  91. package/test/qs.test.ts +79 -0
  92. package/test/regexp.test.ts +97 -0
  93. package/test/string.test.ts +150 -0
  94. package/test/time.test.ts +214 -0
  95. package/test/timer.test.ts +114 -0
  96. package/test/tree.test.ts +348 -0
  97. package/test/type.test.ts +226 -0
  98. package/test/unique.test.ts +71 -0
  99. package/test/url.test.ts +136 -0
  100. package/test/version.test.ts +52 -0
  101. package/tsconfig.json +31 -0
  102. package/vite.config.mts +114 -0
  103. package/dist/array.cjs +0 -129
  104. package/dist/array.cjs.map +0 -1
  105. package/dist/array.d.ts +0 -171
  106. package/dist/array.mjs +0 -129
  107. package/dist/array.mjs.map +0 -1
  108. package/dist/async.cjs +0 -219
  109. package/dist/async.cjs.map +0 -1
  110. package/dist/async.d.ts +0 -137
  111. package/dist/async.mjs +0 -219
  112. package/dist/async.mjs.map +0 -1
  113. package/dist/base64.cjs +0 -16
  114. package/dist/base64.cjs.map +0 -1
  115. package/dist/base64.d.ts +0 -7
  116. package/dist/base64.mjs +0 -16
  117. package/dist/base64.mjs.map +0 -1
  118. package/dist/cache.cjs +0 -79
  119. package/dist/cache.cjs.map +0 -1
  120. package/dist/cache.d.ts +0 -90
  121. package/dist/cache.mjs +0 -79
  122. package/dist/cache.mjs.map +0 -1
  123. package/dist/color/distance.d.ts +0 -8
  124. package/dist/color/helpers.d.ts +0 -2
  125. package/dist/color/hex-hsl.d.ts +0 -3
  126. package/dist/color/hex-rgb.d.ts +0 -18
  127. package/dist/color/rgb-hsl.d.ts +0 -23
  128. package/dist/color/rgb-hwb.d.ts +0 -29
  129. package/dist/color/rgb-whiter.d.ts +0 -12
  130. package/dist/color/rgb-xyz.d.ts +0 -22
  131. package/dist/color.cjs +0 -250
  132. package/dist/color.cjs.map +0 -1
  133. package/dist/color.mjs +0 -250
  134. package/dist/color.mjs.map +0 -1
  135. package/dist/const.cjs +0 -14
  136. package/dist/const.cjs.map +0 -1
  137. package/dist/const.mjs +0 -15
  138. package/dist/const.mjs.map +0 -1
  139. package/dist/core.cjs +0 -250
  140. package/dist/core.cjs.map +0 -1
  141. package/dist/core.mjs +0 -251
  142. package/dist/core.mjs.map +0 -1
  143. package/dist/crypto/md5.d.mts +0 -1
  144. package/dist/crypto/sha1.d.mts +0 -1
  145. package/dist/crypto/sha256.d.mts +0 -1
  146. package/dist/crypto/sha512.d.mts +0 -1
  147. package/dist/crypto.cjs +0 -812
  148. package/dist/crypto.cjs.map +0 -1
  149. package/dist/crypto.mjs +0 -812
  150. package/dist/crypto.mjs.map +0 -1
  151. package/dist/date/const.d.ts +0 -6
  152. package/dist/date/core.d.ts +0 -52
  153. package/dist/date/days.d.ts +0 -23
  154. package/dist/date/relative.d.ts +0 -44
  155. package/dist/date/start-end.d.ts +0 -73
  156. package/dist/date/timezone.d.ts +0 -67
  157. package/dist/date/weeks.d.ts +0 -72
  158. package/dist/date.cjs +0 -239
  159. package/dist/date.cjs.map +0 -1
  160. package/dist/date.mjs +0 -241
  161. package/dist/date.mjs.map +0 -1
  162. package/dist/dict.cjs +0 -2
  163. package/dist/dict.cjs.map +0 -1
  164. package/dist/dict.mjs +0 -2
  165. package/dist/dict.mjs.map +0 -1
  166. package/dist/each.cjs +0 -18
  167. package/dist/each.cjs.map +0 -1
  168. package/dist/each.mjs +0 -19
  169. package/dist/each.mjs.map +0 -1
  170. package/dist/easing.cjs +0 -151
  171. package/dist/easing.cjs.map +0 -1
  172. package/dist/easing.d.ts +0 -46
  173. package/dist/easing.mjs +0 -151
  174. package/dist/easing.mjs.map +0 -1
  175. package/dist/emitter.cjs +0 -94
  176. package/dist/emitter.cjs.map +0 -1
  177. package/dist/emitter.d.ts +0 -68
  178. package/dist/emitter.mjs +0 -94
  179. package/dist/emitter.mjs.map +0 -1
  180. package/dist/enum.cjs +0 -58
  181. package/dist/enum.cjs.map +0 -1
  182. package/dist/enum.d.ts +0 -68
  183. package/dist/enum.mjs +0 -58
  184. package/dist/enum.mjs.map +0 -1
  185. package/dist/env.cjs +0 -28
  186. package/dist/env.cjs.map +0 -1
  187. package/dist/env.mjs +0 -28
  188. package/dist/env.mjs.map +0 -1
  189. package/dist/error.cjs +0 -12
  190. package/dist/error.cjs.map +0 -1
  191. package/dist/error.mjs +0 -12
  192. package/dist/error.mjs.map +0 -1
  193. package/dist/exception.cjs +0 -22
  194. package/dist/exception.cjs.map +0 -1
  195. package/dist/exception.d.ts +0 -31
  196. package/dist/exception.mjs +0 -22
  197. package/dist/exception.mjs.map +0 -1
  198. package/dist/fn.cjs +0 -76
  199. package/dist/fn.cjs.map +0 -1
  200. package/dist/fn.d.ts +0 -102
  201. package/dist/fn.mjs +0 -76
  202. package/dist/fn.mjs.map +0 -1
  203. package/dist/index.cjs +0 -5
  204. package/dist/index.cjs.map +0 -1
  205. package/dist/index.d.ts +0 -1
  206. package/dist/index.mjs +0 -5
  207. package/dist/index.mjs.map +0 -1
  208. package/dist/merge.cjs +0 -87
  209. package/dist/merge.cjs.map +0 -1
  210. package/dist/merge.mjs +0 -88
  211. package/dist/merge.mjs.map +0 -1
  212. package/dist/number.cjs +0 -11
  213. package/dist/number.cjs.map +0 -1
  214. package/dist/number.d.ts +0 -137
  215. package/dist/number.mjs +0 -11
  216. package/dist/number.mjs.map +0 -1
  217. package/dist/object/get-set.d.ts +0 -111
  218. package/dist/object/is.d.ts +0 -32
  219. package/dist/object/merge.d.ts +0 -72
  220. package/dist/object.cjs +0 -130
  221. package/dist/object.cjs.map +0 -1
  222. package/dist/object.mjs +0 -130
  223. package/dist/object.mjs.map +0 -1
  224. package/dist/path.cjs +0 -77
  225. package/dist/path.cjs.map +0 -1
  226. package/dist/path.d.ts +0 -82
  227. package/dist/path.mjs +0 -77
  228. package/dist/path.mjs.map +0 -1
  229. package/dist/promise.cjs +0 -62
  230. package/dist/promise.cjs.map +0 -1
  231. package/dist/promise.mjs +0 -62
  232. package/dist/promise.mjs.map +0 -1
  233. package/dist/qs.cjs +0 -47
  234. package/dist/qs.cjs.map +0 -1
  235. package/dist/qs.mjs +0 -47
  236. package/dist/qs.mjs.map +0 -1
  237. package/dist/regexp.cjs +0 -66
  238. package/dist/regexp.cjs.map +0 -1
  239. package/dist/regexp.d.ts +0 -65
  240. package/dist/regexp.mjs +0 -66
  241. package/dist/regexp.mjs.map +0 -1
  242. package/dist/string.cjs +0 -16
  243. package/dist/string.cjs.map +0 -1
  244. package/dist/string.d.ts +0 -80
  245. package/dist/string.mjs +0 -16
  246. package/dist/string.mjs.map +0 -1
  247. package/dist/string2.cjs +0 -147
  248. package/dist/string2.cjs.map +0 -1
  249. package/dist/string2.mjs +0 -148
  250. package/dist/string2.mjs.map +0 -1
  251. package/dist/time/from.d.ts +0 -14
  252. package/dist/time/to.d.ts +0 -38
  253. package/dist/time.cjs +0 -82
  254. package/dist/time.cjs.map +0 -1
  255. package/dist/time.mjs +0 -82
  256. package/dist/time.mjs.map +0 -1
  257. package/dist/timer.cjs +0 -119
  258. package/dist/timer.cjs.map +0 -1
  259. package/dist/timer.d.ts +0 -96
  260. package/dist/timer.mjs.map +0 -1
  261. package/dist/tree.cjs +0 -125
  262. package/dist/tree.cjs.map +0 -1
  263. package/dist/tree.mjs +0 -125
  264. package/dist/tree.mjs.map +0 -1
  265. package/dist/type.cjs +0 -78
  266. package/dist/type.cjs.map +0 -1
  267. package/dist/type.mjs +0 -78
  268. package/dist/type.mjs.map +0 -1
  269. package/dist/types.cjs +0 -2
  270. package/dist/types.cjs.map +0 -1
  271. package/dist/types.mjs +0 -2
  272. package/dist/types.mjs.map +0 -1
  273. package/dist/unique.cjs +0 -46
  274. package/dist/unique.cjs.map +0 -1
  275. package/dist/unique.d.ts +0 -22
  276. package/dist/unique.mjs +0 -46
  277. package/dist/unique.mjs.map +0 -1
  278. package/dist/url.cjs +0 -37
  279. package/dist/url.cjs.map +0 -1
  280. package/dist/url.d.ts +0 -53
  281. package/dist/url.mjs +0 -37
  282. package/dist/url.mjs.map +0 -1
  283. package/dist/version.cjs +0 -33
  284. package/dist/version.cjs.map +0 -1
  285. package/dist/version.d.ts +0 -32
  286. package/dist/version.mjs +0 -33
  287. package/dist/version.mjs.map +0 -1
  288. /package/{dist/color.d.ts → src/color.ts} +0 -0
  289. /package/{dist/date.d.ts → src/date.ts} +0 -0
  290. /package/{dist/dict.d.ts → src/dict.ts} +0 -0
  291. /package/{dist/object.d.ts → src/object.ts} +0 -0
  292. /package/{dist/time.d.ts → src/time.ts} +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ☁️淡然
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1 +1,279 @@
1
- {"name":"@cloudcome/utils-core","version":"1.1.0","description":"cloudcome core utils","engines":{"node":">=22"},"engineStrict":true,"sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json","./array":{"types":"./dist/array.d.ts","import":"./dist/array.mjs","require":"./dist/array.cjs"},"./async":{"types":"./dist/async.d.ts","import":"./dist/async.mjs","require":"./dist/async.cjs"},"./base64":{"types":"./dist/base64.d.ts","import":"./dist/base64.mjs","require":"./dist/base64.cjs"},"./cache":{"types":"./dist/cache.d.ts","import":"./dist/cache.mjs","require":"./dist/cache.cjs"},"./color":{"types":"./dist/color.d.ts","import":"./dist/color.mjs","require":"./dist/color.cjs"},"./crypto":{"types":"./dist/crypto.d.ts","import":"./dist/crypto.mjs","require":"./dist/crypto.cjs"},"./date":{"types":"./dist/date.d.ts","import":"./dist/date.mjs","require":"./dist/date.cjs"},"./dict":{"types":"./dist/dict.d.ts","import":"./dist/dict.mjs","require":"./dist/dict.cjs"},"./easing":{"types":"./dist/easing.d.ts","import":"./dist/easing.mjs","require":"./dist/easing.cjs"},"./emitter":{"types":"./dist/emitter.d.ts","import":"./dist/emitter.mjs","require":"./dist/emitter.cjs"},"./enum":{"types":"./dist/enum.d.ts","import":"./dist/enum.mjs","require":"./dist/enum.cjs"},"./env":{"types":"./dist/env.d.ts","import":"./dist/env.mjs","require":"./dist/env.cjs"},"./error":{"types":"./dist/error.d.ts","import":"./dist/error.mjs","require":"./dist/error.cjs"},"./exception":{"types":"./dist/exception.d.ts","import":"./dist/exception.mjs","require":"./dist/exception.cjs"},"./fn":{"types":"./dist/fn.d.ts","import":"./dist/fn.mjs","require":"./dist/fn.cjs"},"./number":{"types":"./dist/number.d.ts","import":"./dist/number.mjs","require":"./dist/number.cjs"},"./object":{"types":"./dist/object.d.ts","import":"./dist/object.mjs","require":"./dist/object.cjs"},"./path":{"types":"./dist/path.d.ts","import":"./dist/path.mjs","require":"./dist/path.cjs"},"./promise":{"types":"./dist/promise.d.ts","import":"./dist/promise.mjs","require":"./dist/promise.cjs"},"./qs":{"types":"./dist/qs.d.ts","import":"./dist/qs.mjs","require":"./dist/qs.cjs"},"./regexp":{"types":"./dist/regexp.d.ts","import":"./dist/regexp.mjs","require":"./dist/regexp.cjs"},"./string":{"types":"./dist/string.d.ts","import":"./dist/string.mjs","require":"./dist/string.cjs"},"./time":{"types":"./dist/time.d.ts","import":"./dist/time.mjs","require":"./dist/time.cjs"},"./timer":{"types":"./dist/timer.d.ts","import":"./dist/timer.mjs","require":"./dist/timer.cjs"},"./tree":{"types":"./dist/tree.d.ts","import":"./dist/tree.mjs","require":"./dist/tree.cjs"},"./type":{"types":"./dist/type.d.ts","import":"./dist/type.mjs","require":"./dist/type.cjs"},"./types":{"types":"./dist/types.d.ts","import":"./dist/types.mjs","require":"./dist/types.cjs"},"./unique":{"types":"./dist/unique.d.ts","import":"./dist/unique.mjs","require":"./dist/unique.cjs"},"./url":{"types":"./dist/url.d.ts","import":"./dist/url.mjs","require":"./dist/url.cjs"},"./version":{"types":"./dist/version.d.ts","import":"./dist/version.mjs","require":"./dist/version.cjs"}},"typesVersions":{"*":{"array":["./dist/array.d.ts"],"async":["./dist/async.d.ts"],"base64":["./dist/base64.d.ts"],"cache":["./dist/cache.d.ts"],"color":["./dist/color.d.ts"],"crypto":["./dist/crypto.d.ts"],"date":["./dist/date.d.ts"],"dict":["./dist/dict.d.ts"],"easing":["./dist/easing.d.ts"],"emitter":["./dist/emitter.d.ts"],"enum":["./dist/enum.d.ts"],"env":["./dist/env.d.ts"],"error":["./dist/error.d.ts"],"exception":["./dist/exception.d.ts"],"fn":["./dist/fn.d.ts"],"number":["./dist/number.d.ts"],"object":["./dist/object.d.ts"],"path":["./dist/path.d.ts"],"promise":["./dist/promise.d.ts"],"qs":["./dist/qs.d.ts"],"regexp":["./dist/regexp.d.ts"],"string":["./dist/string.d.ts"],"time":["./dist/time.d.ts"],"timer":["./dist/timer.d.ts"],"tree":["./dist/tree.d.ts"],"type":["./dist/type.d.ts"],"types":["./dist/types.d.ts"],"unique":["./dist/unique.d.ts"],"url":["./dist/url.d.ts"],"version":["./dist/version.d.ts"]}},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","files":["dist"],"repository":{"url":"https://github.com/cloudcome/utils","directory":"packages/utils-core"}}
1
+ {
2
+ "name": "@cloudcome/utils-core",
3
+ "version": "1.1.1",
4
+ "description": "cloudcome core utils",
5
+ "engines": {
6
+ "node": ">=22"
7
+ },
8
+ "engineStrict": true,
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.cjs"
15
+ },
16
+ "./package.json": "./package.json",
17
+ "./array": {
18
+ "types": "./dist/array.d.ts",
19
+ "import": "./dist/array.mjs",
20
+ "require": "./dist/array.cjs"
21
+ },
22
+ "./async": {
23
+ "types": "./dist/async.d.ts",
24
+ "import": "./dist/async.mjs",
25
+ "require": "./dist/async.cjs"
26
+ },
27
+ "./base64": {
28
+ "types": "./dist/base64.d.ts",
29
+ "import": "./dist/base64.mjs",
30
+ "require": "./dist/base64.cjs"
31
+ },
32
+ "./cache": {
33
+ "types": "./dist/cache.d.ts",
34
+ "import": "./dist/cache.mjs",
35
+ "require": "./dist/cache.cjs"
36
+ },
37
+ "./color": {
38
+ "types": "./dist/color.d.ts",
39
+ "import": "./dist/color.mjs",
40
+ "require": "./dist/color.cjs"
41
+ },
42
+ "./crypto": {
43
+ "types": "./dist/crypto.d.ts",
44
+ "import": "./dist/crypto.mjs",
45
+ "require": "./dist/crypto.cjs"
46
+ },
47
+ "./date": {
48
+ "types": "./dist/date.d.ts",
49
+ "import": "./dist/date.mjs",
50
+ "require": "./dist/date.cjs"
51
+ },
52
+ "./dict": {
53
+ "types": "./dist/dict.d.ts",
54
+ "import": "./dist/dict.mjs",
55
+ "require": "./dist/dict.cjs"
56
+ },
57
+ "./easing": {
58
+ "types": "./dist/easing.d.ts",
59
+ "import": "./dist/easing.mjs",
60
+ "require": "./dist/easing.cjs"
61
+ },
62
+ "./emitter": {
63
+ "types": "./dist/emitter.d.ts",
64
+ "import": "./dist/emitter.mjs",
65
+ "require": "./dist/emitter.cjs"
66
+ },
67
+ "./enum": {
68
+ "types": "./dist/enum.d.ts",
69
+ "import": "./dist/enum.mjs",
70
+ "require": "./dist/enum.cjs"
71
+ },
72
+ "./env": {
73
+ "types": "./dist/env.d.ts",
74
+ "import": "./dist/env.mjs",
75
+ "require": "./dist/env.cjs"
76
+ },
77
+ "./error": {
78
+ "types": "./dist/error.d.ts",
79
+ "import": "./dist/error.mjs",
80
+ "require": "./dist/error.cjs"
81
+ },
82
+ "./exception": {
83
+ "types": "./dist/exception.d.ts",
84
+ "import": "./dist/exception.mjs",
85
+ "require": "./dist/exception.cjs"
86
+ },
87
+ "./fn": {
88
+ "types": "./dist/fn.d.ts",
89
+ "import": "./dist/fn.mjs",
90
+ "require": "./dist/fn.cjs"
91
+ },
92
+ "./number": {
93
+ "types": "./dist/number.d.ts",
94
+ "import": "./dist/number.mjs",
95
+ "require": "./dist/number.cjs"
96
+ },
97
+ "./object": {
98
+ "types": "./dist/object.d.ts",
99
+ "import": "./dist/object.mjs",
100
+ "require": "./dist/object.cjs"
101
+ },
102
+ "./path": {
103
+ "types": "./dist/path.d.ts",
104
+ "import": "./dist/path.mjs",
105
+ "require": "./dist/path.cjs"
106
+ },
107
+ "./promise": {
108
+ "types": "./dist/promise.d.ts",
109
+ "import": "./dist/promise.mjs",
110
+ "require": "./dist/promise.cjs"
111
+ },
112
+ "./qs": {
113
+ "types": "./dist/qs.d.ts",
114
+ "import": "./dist/qs.mjs",
115
+ "require": "./dist/qs.cjs"
116
+ },
117
+ "./regexp": {
118
+ "types": "./dist/regexp.d.ts",
119
+ "import": "./dist/regexp.mjs",
120
+ "require": "./dist/regexp.cjs"
121
+ },
122
+ "./string": {
123
+ "types": "./dist/string.d.ts",
124
+ "import": "./dist/string.mjs",
125
+ "require": "./dist/string.cjs"
126
+ },
127
+ "./time": {
128
+ "types": "./dist/time.d.ts",
129
+ "import": "./dist/time.mjs",
130
+ "require": "./dist/time.cjs"
131
+ },
132
+ "./timer": {
133
+ "types": "./dist/timer.d.ts",
134
+ "import": "./dist/timer.mjs",
135
+ "require": "./dist/timer.cjs"
136
+ },
137
+ "./tree": {
138
+ "types": "./dist/tree.d.ts",
139
+ "import": "./dist/tree.mjs",
140
+ "require": "./dist/tree.cjs"
141
+ },
142
+ "./type": {
143
+ "types": "./dist/type.d.ts",
144
+ "import": "./dist/type.mjs",
145
+ "require": "./dist/type.cjs"
146
+ },
147
+ "./types": {
148
+ "types": "./dist/types.d.ts",
149
+ "import": "./dist/types.mjs",
150
+ "require": "./dist/types.cjs"
151
+ },
152
+ "./unique": {
153
+ "types": "./dist/unique.d.ts",
154
+ "import": "./dist/unique.mjs",
155
+ "require": "./dist/unique.cjs"
156
+ },
157
+ "./url": {
158
+ "types": "./dist/url.d.ts",
159
+ "import": "./dist/url.mjs",
160
+ "require": "./dist/url.cjs"
161
+ },
162
+ "./version": {
163
+ "types": "./dist/version.d.ts",
164
+ "import": "./dist/version.mjs",
165
+ "require": "./dist/version.cjs"
166
+ }
167
+ },
168
+ "typesVersions": {
169
+ "*": {
170
+ "array": [
171
+ "./dist/array.d.ts"
172
+ ],
173
+ "async": [
174
+ "./dist/async.d.ts"
175
+ ],
176
+ "base64": [
177
+ "./dist/base64.d.ts"
178
+ ],
179
+ "cache": [
180
+ "./dist/cache.d.ts"
181
+ ],
182
+ "color": [
183
+ "./dist/color.d.ts"
184
+ ],
185
+ "crypto": [
186
+ "./dist/crypto.d.ts"
187
+ ],
188
+ "date": [
189
+ "./dist/date.d.ts"
190
+ ],
191
+ "dict": [
192
+ "./dist/dict.d.ts"
193
+ ],
194
+ "easing": [
195
+ "./dist/easing.d.ts"
196
+ ],
197
+ "emitter": [
198
+ "./dist/emitter.d.ts"
199
+ ],
200
+ "enum": [
201
+ "./dist/enum.d.ts"
202
+ ],
203
+ "env": [
204
+ "./dist/env.d.ts"
205
+ ],
206
+ "error": [
207
+ "./dist/error.d.ts"
208
+ ],
209
+ "exception": [
210
+ "./dist/exception.d.ts"
211
+ ],
212
+ "fn": [
213
+ "./dist/fn.d.ts"
214
+ ],
215
+ "number": [
216
+ "./dist/number.d.ts"
217
+ ],
218
+ "object": [
219
+ "./dist/object.d.ts"
220
+ ],
221
+ "path": [
222
+ "./dist/path.d.ts"
223
+ ],
224
+ "promise": [
225
+ "./dist/promise.d.ts"
226
+ ],
227
+ "qs": [
228
+ "./dist/qs.d.ts"
229
+ ],
230
+ "regexp": [
231
+ "./dist/regexp.d.ts"
232
+ ],
233
+ "string": [
234
+ "./dist/string.d.ts"
235
+ ],
236
+ "time": [
237
+ "./dist/time.d.ts"
238
+ ],
239
+ "timer": [
240
+ "./dist/timer.d.ts"
241
+ ],
242
+ "tree": [
243
+ "./dist/tree.d.ts"
244
+ ],
245
+ "type": [
246
+ "./dist/type.d.ts"
247
+ ],
248
+ "types": [
249
+ "./dist/types.d.ts"
250
+ ],
251
+ "unique": [
252
+ "./dist/unique.d.ts"
253
+ ],
254
+ "url": [
255
+ "./dist/url.d.ts"
256
+ ],
257
+ "version": [
258
+ "./dist/version.d.ts"
259
+ ]
260
+ }
261
+ },
262
+ "main": "./dist/index.cjs",
263
+ "module": "./dist/index.mjs",
264
+ "types": "./dist/index.d.ts",
265
+ "repository": "https://github.com/cloudcome/utils",
266
+ "keywords": [
267
+ "utils",
268
+ "cloudcome",
269
+ "utils-core",
270
+ "utils-vue",
271
+ "utils-react",
272
+ "utils-uni",
273
+ "utils-node",
274
+ "utils-browser"
275
+ ],
276
+ "homepage": "https://github.com/cloudcome/utils",
277
+ "license": "MIT",
278
+ "author": "云淡然 <hi@ydr.me> (https://ydr.me/)"
279
+ }
package/src/array.ts ADDED
@@ -0,0 +1,312 @@
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
+ }