@alibarbar/common 1.0.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 (210) hide show
  1. package/README.md +338 -0
  2. package/dist/algorithm.d.mts +66 -0
  3. package/dist/algorithm.d.ts +66 -0
  4. package/dist/algorithm.js +44 -0
  5. package/dist/algorithm.js.map +1 -0
  6. package/dist/algorithm.mjs +3 -0
  7. package/dist/algorithm.mjs.map +1 -0
  8. package/dist/array.d.mts +139 -0
  9. package/dist/array.d.ts +139 -0
  10. package/dist/array.js +84 -0
  11. package/dist/array.js.map +1 -0
  12. package/dist/array.mjs +3 -0
  13. package/dist/array.mjs.map +1 -0
  14. package/dist/chunk-27UDDVLZ.js +259 -0
  15. package/dist/chunk-27UDDVLZ.js.map +1 -0
  16. package/dist/chunk-2FFSQ573.mjs +138 -0
  17. package/dist/chunk-2FFSQ573.mjs.map +1 -0
  18. package/dist/chunk-4RGXV4SJ.js +106 -0
  19. package/dist/chunk-4RGXV4SJ.js.map +1 -0
  20. package/dist/chunk-56W6YECK.js +374 -0
  21. package/dist/chunk-56W6YECK.js.map +1 -0
  22. package/dist/chunk-5BGSUGTI.mjs +128 -0
  23. package/dist/chunk-5BGSUGTI.mjs.map +1 -0
  24. package/dist/chunk-7E6GELHJ.mjs +302 -0
  25. package/dist/chunk-7E6GELHJ.mjs.map +1 -0
  26. package/dist/chunk-7V5UQXIO.js +89 -0
  27. package/dist/chunk-7V5UQXIO.js.map +1 -0
  28. package/dist/chunk-A4SWQXX7.mjs +484 -0
  29. package/dist/chunk-A4SWQXX7.mjs.map +1 -0
  30. package/dist/chunk-ALDC6LRJ.mjs +85 -0
  31. package/dist/chunk-ALDC6LRJ.mjs.map +1 -0
  32. package/dist/chunk-BHCRFURU.js +491 -0
  33. package/dist/chunk-BHCRFURU.js.map +1 -0
  34. package/dist/chunk-D7CS5EKF.js +110 -0
  35. package/dist/chunk-D7CS5EKF.js.map +1 -0
  36. package/dist/chunk-DYBSRI7V.js +189 -0
  37. package/dist/chunk-DYBSRI7V.js.map +1 -0
  38. package/dist/chunk-F3LAGHPG.js +332 -0
  39. package/dist/chunk-F3LAGHPG.js.map +1 -0
  40. package/dist/chunk-HLDFI7R2.mjs +175 -0
  41. package/dist/chunk-HLDFI7R2.mjs.map +1 -0
  42. package/dist/chunk-HME2N3VY.mjs +354 -0
  43. package/dist/chunk-HME2N3VY.mjs.map +1 -0
  44. package/dist/chunk-I3L42475.js +145 -0
  45. package/dist/chunk-I3L42475.js.map +1 -0
  46. package/dist/chunk-JBLX27WD.mjs +240 -0
  47. package/dist/chunk-JBLX27WD.mjs.map +1 -0
  48. package/dist/chunk-JHZ7M2MR.mjs +133 -0
  49. package/dist/chunk-JHZ7M2MR.mjs.map +1 -0
  50. package/dist/chunk-JK2SE3I2.js +100 -0
  51. package/dist/chunk-JK2SE3I2.js.map +1 -0
  52. package/dist/chunk-JQZBPAPO.js +157 -0
  53. package/dist/chunk-JQZBPAPO.js.map +1 -0
  54. package/dist/chunk-JXYGC2C5.mjs +100 -0
  55. package/dist/chunk-JXYGC2C5.mjs.map +1 -0
  56. package/dist/chunk-KGFTD255.js +104 -0
  57. package/dist/chunk-KGFTD255.js.map +1 -0
  58. package/dist/chunk-LBHBNPNJ.mjs +148 -0
  59. package/dist/chunk-LBHBNPNJ.mjs.map +1 -0
  60. package/dist/chunk-LCXGZISK.js +158 -0
  61. package/dist/chunk-LCXGZISK.js.map +1 -0
  62. package/dist/chunk-LF4CILQS.mjs +87 -0
  63. package/dist/chunk-LF4CILQS.mjs.map +1 -0
  64. package/dist/chunk-MMR6XQNX.js +98 -0
  65. package/dist/chunk-MMR6XQNX.js.map +1 -0
  66. package/dist/chunk-NSSDYX2U.mjs +80 -0
  67. package/dist/chunk-NSSDYX2U.mjs.map +1 -0
  68. package/dist/chunk-O3O67R4I.js +143 -0
  69. package/dist/chunk-O3O67R4I.js.map +1 -0
  70. package/dist/chunk-OX5PLOWB.js +90 -0
  71. package/dist/chunk-OX5PLOWB.js.map +1 -0
  72. package/dist/chunk-PJ7UCTX4.mjs +362 -0
  73. package/dist/chunk-PJ7UCTX4.mjs.map +1 -0
  74. package/dist/chunk-QIBE7GVN.mjs +81 -0
  75. package/dist/chunk-QIBE7GVN.mjs.map +1 -0
  76. package/dist/chunk-QIOC54LQ.mjs +130 -0
  77. package/dist/chunk-QIOC54LQ.mjs.map +1 -0
  78. package/dist/chunk-QV6MIQ7H.mjs +328 -0
  79. package/dist/chunk-QV6MIQ7H.mjs.map +1 -0
  80. package/dist/chunk-TQN37HIN.js +94 -0
  81. package/dist/chunk-TQN37HIN.js.map +1 -0
  82. package/dist/chunk-XJTZDXSR.mjs +94 -0
  83. package/dist/chunk-XJTZDXSR.mjs.map +1 -0
  84. package/dist/chunk-XVUE53T3.js +361 -0
  85. package/dist/chunk-XVUE53T3.js.map +1 -0
  86. package/dist/chunk-Y364QIQH.js +139 -0
  87. package/dist/chunk-Y364QIQH.js.map +1 -0
  88. package/dist/chunk-YXM6Q4JS.mjs +94 -0
  89. package/dist/chunk-YXM6Q4JS.mjs.map +1 -0
  90. package/dist/chunk-ZDMFMUDR.js +309 -0
  91. package/dist/chunk-ZDMFMUDR.js.map +1 -0
  92. package/dist/chunk-ZVJ6NQUM.mjs +82 -0
  93. package/dist/chunk-ZVJ6NQUM.mjs.map +1 -0
  94. package/dist/color.d.mts +74 -0
  95. package/dist/color.d.ts +74 -0
  96. package/dist/color.js +40 -0
  97. package/dist/color.js.map +1 -0
  98. package/dist/color.mjs +3 -0
  99. package/dist/color.mjs.map +1 -0
  100. package/dist/crypto.d.mts +92 -0
  101. package/dist/crypto.d.ts +92 -0
  102. package/dist/crypto.js +60 -0
  103. package/dist/crypto.js.map +1 -0
  104. package/dist/crypto.mjs +3 -0
  105. package/dist/crypto.mjs.map +1 -0
  106. package/dist/data-structure.d.mts +213 -0
  107. package/dist/data-structure.d.ts +213 -0
  108. package/dist/data-structure.js +32 -0
  109. package/dist/data-structure.js.map +1 -0
  110. package/dist/data-structure.mjs +3 -0
  111. package/dist/data-structure.mjs.map +1 -0
  112. package/dist/date.d.mts +108 -0
  113. package/dist/date.d.ts +108 -0
  114. package/dist/date.js +72 -0
  115. package/dist/date.js.map +1 -0
  116. package/dist/date.mjs +3 -0
  117. package/dist/date.mjs.map +1 -0
  118. package/dist/dom.d.mts +92 -0
  119. package/dist/dom.d.ts +92 -0
  120. package/dist/dom.js +56 -0
  121. package/dist/dom.js.map +1 -0
  122. package/dist/dom.mjs +3 -0
  123. package/dist/dom.mjs.map +1 -0
  124. package/dist/file.d.mts +44 -0
  125. package/dist/file.d.ts +44 -0
  126. package/dist/file.js +32 -0
  127. package/dist/file.js.map +1 -0
  128. package/dist/file.mjs +3 -0
  129. package/dist/file.mjs.map +1 -0
  130. package/dist/i18n.d.mts +77 -0
  131. package/dist/i18n.d.ts +77 -0
  132. package/dist/i18n.js +40 -0
  133. package/dist/i18n.js.map +1 -0
  134. package/dist/i18n.mjs +3 -0
  135. package/dist/i18n.mjs.map +1 -0
  136. package/dist/index.d.mts +155 -0
  137. package/dist/index.d.ts +155 -0
  138. package/dist/index.js +839 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/index.mjs +22 -0
  141. package/dist/index.mjs.map +1 -0
  142. package/dist/network.d.mts +47 -0
  143. package/dist/network.d.ts +47 -0
  144. package/dist/network.js +28 -0
  145. package/dist/network.js.map +1 -0
  146. package/dist/network.mjs +3 -0
  147. package/dist/network.mjs.map +1 -0
  148. package/dist/number.d.mts +100 -0
  149. package/dist/number.d.ts +100 -0
  150. package/dist/number.js +56 -0
  151. package/dist/number.js.map +1 -0
  152. package/dist/number.mjs +3 -0
  153. package/dist/number.mjs.map +1 -0
  154. package/dist/object.d.mts +132 -0
  155. package/dist/object.d.ts +132 -0
  156. package/dist/object.js +80 -0
  157. package/dist/object.js.map +1 -0
  158. package/dist/object.mjs +3 -0
  159. package/dist/object.mjs.map +1 -0
  160. package/dist/performance.d.mts +85 -0
  161. package/dist/performance.d.ts +85 -0
  162. package/dist/performance.js +40 -0
  163. package/dist/performance.js.map +1 -0
  164. package/dist/performance.mjs +3 -0
  165. package/dist/performance.mjs.map +1 -0
  166. package/dist/storage.d.mts +176 -0
  167. package/dist/storage.d.ts +176 -0
  168. package/dist/storage.js +33 -0
  169. package/dist/storage.js.map +1 -0
  170. package/dist/storage.mjs +4 -0
  171. package/dist/storage.mjs.map +1 -0
  172. package/dist/string.d.mts +105 -0
  173. package/dist/string.d.ts +105 -0
  174. package/dist/string.js +68 -0
  175. package/dist/string.js.map +1 -0
  176. package/dist/string.mjs +3 -0
  177. package/dist/string.mjs.map +1 -0
  178. package/dist/tracking.d.mts +182 -0
  179. package/dist/tracking.d.ts +182 -0
  180. package/dist/tracking.js +52 -0
  181. package/dist/tracking.js.map +1 -0
  182. package/dist/tracking.mjs +3 -0
  183. package/dist/tracking.mjs.map +1 -0
  184. package/dist/transform.d.mts +53 -0
  185. package/dist/transform.d.ts +53 -0
  186. package/dist/transform.js +32 -0
  187. package/dist/transform.js.map +1 -0
  188. package/dist/transform.mjs +3 -0
  189. package/dist/transform.mjs.map +1 -0
  190. package/dist/upload-DzlQtUBc.d.mts +202 -0
  191. package/dist/upload-DzlQtUBc.d.ts +202 -0
  192. package/dist/upload.d.mts +1 -0
  193. package/dist/upload.d.ts +1 -0
  194. package/dist/upload.js +17 -0
  195. package/dist/upload.js.map +1 -0
  196. package/dist/upload.mjs +4 -0
  197. package/dist/upload.mjs.map +1 -0
  198. package/dist/url.d.mts +82 -0
  199. package/dist/url.d.ts +82 -0
  200. package/dist/url.js +44 -0
  201. package/dist/url.js.map +1 -0
  202. package/dist/url.mjs +3 -0
  203. package/dist/url.mjs.map +1 -0
  204. package/dist/validation.d.mts +83 -0
  205. package/dist/validation.d.ts +83 -0
  206. package/dist/validation.js +60 -0
  207. package/dist/validation.js.map +1 -0
  208. package/dist/validation.mjs +3 -0
  209. package/dist/validation.mjs.map +1 -0
  210. package/package.json +170 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/dist/index.mjs ADDED
@@ -0,0 +1,22 @@
1
+ export { BinaryTree, DataQueue, Graph, LRUCache, LinkedList, Stack } from './chunk-A4SWQXX7.mjs';
2
+ export { binarySearch, bubbleSort, factorial, fibonacci, fibonacciSequence, gcd, lcm, mergeSort, quickSort } from './chunk-JHZ7M2MR.mjs';
3
+ export { Queue, batch, debounce, memoize, once, retry, throttle, timeout } from './chunk-LBHBNPNJ.mjs';
4
+ export { Tracker, createTracker, flush, getTracker, initTracker, setCommonParams, setUserInfo, trackClick, trackEvent, trackExposure, trackPageView } from './chunk-PJ7UCTX4.mjs';
5
+ export { contrast, darken, hexToRgb, hslToRgb, lighten, mix, rgbToHex, rgbToHsl } from './chunk-QIOC54LQ.mjs';
6
+ export { createTranslator, formatCurrencyI18n, formatDateI18n, formatNumberI18n, formatRelativeTime, getLocale, pluralize, translate } from './chunk-QIBE7GVN.mjs';
7
+ export { ChunkUploader, UploadStatus, createUploader } from './chunk-QV6MIQ7H.mjs';
8
+ export { calculateBlobMD5, calculateFileMD5, formatFileSize, getFileExtension, getFileNameWithoutExtension, splitFileIntoChunks } from './chunk-ZVJ6NQUM.mjs';
9
+ export { cookie, getStorageKeyPair, localStorage, sessionStorage, setStorageKeyPair, storage } from './chunk-HME2N3VY.mjs';
10
+ export { base64Decode, base64Encode, exportPrivateKey, exportPublicKey, generateRSAKeyPair, generateRandomString, generateUUID, hash, importPrivateKey, importPublicKey, rsaDecrypt, rsaEncrypt, sha256 } from './chunk-HLDFI7R2.mjs';
11
+ export { checkOnline, downloadFile, fetchWithRetry, fetchWithTimeout, request } from './chunk-JXYGC2C5.mjs';
12
+ export { $, $$, addClass, copyToClipboard, getElementOffset, getScrollPosition, getStyle, isInViewport, removeClass, scrollTo, setStyle, toggleClass } from './chunk-LF4CILQS.mjs';
13
+ export { csvToJson, jsonToCsv, jsonToXml, jsonToYaml, xmlToJson, yamlToJson } from './chunk-7E6GELHJ.mjs';
14
+ export { camelCase, capitalize, escapeHtml, highlight, kebabCase, mask, maskEmail, maskPhone, pascalCase, removeAccents, slugify, snakeCase, template, truncate, unescapeHtml } from './chunk-XJTZDXSR.mjs';
15
+ export { chunk, compact, difference, drop, dropWhile, findIndexBy, flatten, groupBy, intersection, partition, sample, shuffle, sortBy, take, takeWhile, union, unique, unzip, zip } from './chunk-2FFSQ573.mjs';
16
+ export { deepClone, deepMerge, defaults, get, invert, isEmptyObject, isEqual, keys, mapKeys, mapValues, merge, omit, omitBy, pick, pickBy, set, transform, values } from './chunk-JBLX27WD.mjs';
17
+ export { addDays, addMonths, addYears, diffDays, endOfDay, formatDate, getDateFormatByGMT, getQuarter, getRelativeTime, getTimeFromGMT, getWeekNumber, isToday, isWeekday, isWeekend, isYesterday, startOfDay } from './chunk-5BGSUGTI.mjs';
18
+ export { isEmpty, isFloat, isInteger, isNumeric, isValidDomain, isValidEmail, isValidHexColor, isValidIP, isValidIdCard, isValidJSON, isValidPhone, isValidUUID, isValidUrl } from './chunk-NSSDYX2U.mjs';
19
+ export { ceil, clamp, floor, formatBytes, formatCurrency, formatNumber, isBetween, parseNumber, percent, random, round, toFixed } from './chunk-ALDC6LRJ.mjs';
20
+ export { buildUrl, getQueryParams, isAbsoluteUrl, joinUrl, normalizeUrl, parseUrl, removeQueryParams, setQueryParams, updateQueryParams } from './chunk-YXM6Q4JS.mjs';
21
+ //# sourceMappingURL=index.mjs.map
22
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 网络工具函数
3
+ */
4
+ /**
5
+ * 带重试的fetch
6
+ * @param url - 请求URL
7
+ * @param options - fetch选项
8
+ * @param retryCount - 重试次数,默认为 3
9
+ * @param retryDelay - 重试延迟(毫秒),默认为 1000
10
+ * @returns Promise<Response>
11
+ */
12
+ declare function fetchWithRetry(url: string, options?: RequestInit, retryCount?: number, retryDelay?: number): Promise<Response>;
13
+ /**
14
+ * 带超时的fetch
15
+ * @param url - 请求URL
16
+ * @param options - fetch选项
17
+ * @param timeout - 超时时间(毫秒),默认为 5000
18
+ * @returns Promise<Response>
19
+ */
20
+ declare function fetchWithTimeout(url: string, options?: RequestInit, timeout?: number): Promise<Response>;
21
+ /**
22
+ * 文件下载
23
+ * @param url - 文件URL
24
+ * @param filename - 文件名,可选
25
+ * @returns Promise<void>
26
+ */
27
+ declare function downloadFile(url: string, filename?: string): Promise<void>;
28
+ /**
29
+ * 检查网络状态
30
+ * @returns 是否在线
31
+ */
32
+ declare function checkOnline(): boolean;
33
+ /**
34
+ * 统一的HTTP请求封装
35
+ * @param url - 请求URL
36
+ * @param options - 请求选项
37
+ * @returns Promise<T>
38
+ */
39
+ declare function request<T = unknown>(url: string, options?: {
40
+ method?: string;
41
+ headers?: Record<string, string>;
42
+ body?: unknown;
43
+ timeout?: number;
44
+ retry?: number;
45
+ }): Promise<T>;
46
+
47
+ export { checkOnline, downloadFile, fetchWithRetry, fetchWithTimeout, request };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 网络工具函数
3
+ */
4
+ /**
5
+ * 带重试的fetch
6
+ * @param url - 请求URL
7
+ * @param options - fetch选项
8
+ * @param retryCount - 重试次数,默认为 3
9
+ * @param retryDelay - 重试延迟(毫秒),默认为 1000
10
+ * @returns Promise<Response>
11
+ */
12
+ declare function fetchWithRetry(url: string, options?: RequestInit, retryCount?: number, retryDelay?: number): Promise<Response>;
13
+ /**
14
+ * 带超时的fetch
15
+ * @param url - 请求URL
16
+ * @param options - fetch选项
17
+ * @param timeout - 超时时间(毫秒),默认为 5000
18
+ * @returns Promise<Response>
19
+ */
20
+ declare function fetchWithTimeout(url: string, options?: RequestInit, timeout?: number): Promise<Response>;
21
+ /**
22
+ * 文件下载
23
+ * @param url - 文件URL
24
+ * @param filename - 文件名,可选
25
+ * @returns Promise<void>
26
+ */
27
+ declare function downloadFile(url: string, filename?: string): Promise<void>;
28
+ /**
29
+ * 检查网络状态
30
+ * @returns 是否在线
31
+ */
32
+ declare function checkOnline(): boolean;
33
+ /**
34
+ * 统一的HTTP请求封装
35
+ * @param url - 请求URL
36
+ * @param options - 请求选项
37
+ * @returns Promise<T>
38
+ */
39
+ declare function request<T = unknown>(url: string, options?: {
40
+ method?: string;
41
+ headers?: Record<string, string>;
42
+ body?: unknown;
43
+ timeout?: number;
44
+ retry?: number;
45
+ }): Promise<T>;
46
+
47
+ export { checkOnline, downloadFile, fetchWithRetry, fetchWithTimeout, request };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var chunk4RGXV4SJ_js = require('./chunk-4RGXV4SJ.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "checkOnline", {
8
+ enumerable: true,
9
+ get: function () { return chunk4RGXV4SJ_js.checkOnline; }
10
+ });
11
+ Object.defineProperty(exports, "downloadFile", {
12
+ enumerable: true,
13
+ get: function () { return chunk4RGXV4SJ_js.downloadFile; }
14
+ });
15
+ Object.defineProperty(exports, "fetchWithRetry", {
16
+ enumerable: true,
17
+ get: function () { return chunk4RGXV4SJ_js.fetchWithRetry; }
18
+ });
19
+ Object.defineProperty(exports, "fetchWithTimeout", {
20
+ enumerable: true,
21
+ get: function () { return chunk4RGXV4SJ_js.fetchWithTimeout; }
22
+ });
23
+ Object.defineProperty(exports, "request", {
24
+ enumerable: true,
25
+ get: function () { return chunk4RGXV4SJ_js.request; }
26
+ });
27
+ //# sourceMappingURL=network.js.map
28
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"network.js"}
@@ -0,0 +1,3 @@
1
+ export { checkOnline, downloadFile, fetchWithRetry, fetchWithTimeout, request } from './chunk-JXYGC2C5.mjs';
2
+ //# sourceMappingURL=network.mjs.map
3
+ //# sourceMappingURL=network.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"network.mjs"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 数字工具函数
3
+ */
4
+ /**
5
+ * 数字格式化(千分位)
6
+ * @param num - 数字
7
+ * @param options - 格式化选项
8
+ * @returns 格式化后的字符串
9
+ */
10
+ declare function formatNumber(num: number, options?: {
11
+ decimals?: number;
12
+ separator?: string;
13
+ decimalPoint?: string;
14
+ minimumFractionDigits?: number;
15
+ }): string;
16
+ /**
17
+ * 生成随机数
18
+ * @param min - 最小值
19
+ * @param max - 最大值
20
+ * @param integer - 是否为整数,默认为 false
21
+ * @returns 随机数
22
+ */
23
+ declare function random(min: number, max: number, integer?: boolean): number;
24
+ /**
25
+ * 限制数值范围
26
+ * @param num - 数字
27
+ * @param min - 最小值
28
+ * @param max - 最大值
29
+ * @returns 限制后的数字
30
+ */
31
+ declare function clamp(num: number, min: number, max: number): number;
32
+ /**
33
+ * 增强版四舍五入
34
+ * @param num - 数字
35
+ * @param decimals - 小数位数,默认为 0
36
+ * @returns 四舍五入后的数字
37
+ */
38
+ declare function round(num: number, decimals?: number): number;
39
+ /**
40
+ * 增强版向下取整
41
+ * @param num - 数字
42
+ * @param decimals - 小数位数,默认为 0
43
+ * @returns 向下取整后的数字
44
+ */
45
+ declare function floor(num: number, decimals?: number): number;
46
+ /**
47
+ * 增强版向上取整
48
+ * @param num - 数字
49
+ * @param decimals - 小数位数,默认为 0
50
+ * @returns 向上取整后的数字
51
+ */
52
+ declare function ceil(num: number, decimals?: number): number;
53
+ /**
54
+ * 保留小数位(增强版)
55
+ * @param num - 数字
56
+ * @param decimals - 小数位数
57
+ * @returns 格式化后的字符串
58
+ */
59
+ declare function toFixed(num: number, decimals: number): string;
60
+ /**
61
+ * 解析数字字符串
62
+ * @param str - 数字字符串
63
+ * @param defaultValue - 默认值,解析失败时返回
64
+ * @returns 解析后的数字
65
+ */
66
+ declare function parseNumber(str: string, defaultValue?: number): number;
67
+ /**
68
+ * 判断是否在范围内
69
+ * @param num - 数字
70
+ * @param min - 最小值
71
+ * @param max - 最大值
72
+ * @param inclusive - 是否包含边界,默认为 true
73
+ * @returns 是否在范围内
74
+ */
75
+ declare function isBetween(num: number, min: number, max: number, inclusive?: boolean): boolean;
76
+ /**
77
+ * 百分比计算
78
+ * @param value - 当前值(0-1之间的小数)或当前值(当提供total时)
79
+ * @param decimals - 小数位数,默认为 0(当value是0-1之间的小数时)或总值(当value是实际值时)
80
+ * @returns 百分比数字(当value是0-1之间的小数时)或百分比字符串(当提供total时)
81
+ */
82
+ declare function percent(value: number, decimals?: number): number;
83
+ declare function percent(value: number, total: number, decimals: number): string;
84
+ /**
85
+ * 货币格式化
86
+ * @param num - 数字
87
+ * @param currency - 货币符号,默认为 '¥'
88
+ * @param decimals - 小数位数,默认为 2
89
+ * @returns 格式化后的货币字符串
90
+ */
91
+ declare function formatCurrency(num: number, currency?: string, decimals?: number): string;
92
+ /**
93
+ * 字节格式化
94
+ * @param bytes - 字节数
95
+ * @param decimals - 小数位数,默认为 2
96
+ * @returns 格式化后的字节字符串
97
+ */
98
+ declare function formatBytes(bytes: number, decimals?: number): string;
99
+
100
+ export { ceil, clamp, floor, formatBytes, formatCurrency, formatNumber, isBetween, parseNumber, percent, random, round, toFixed };
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 数字工具函数
3
+ */
4
+ /**
5
+ * 数字格式化(千分位)
6
+ * @param num - 数字
7
+ * @param options - 格式化选项
8
+ * @returns 格式化后的字符串
9
+ */
10
+ declare function formatNumber(num: number, options?: {
11
+ decimals?: number;
12
+ separator?: string;
13
+ decimalPoint?: string;
14
+ minimumFractionDigits?: number;
15
+ }): string;
16
+ /**
17
+ * 生成随机数
18
+ * @param min - 最小值
19
+ * @param max - 最大值
20
+ * @param integer - 是否为整数,默认为 false
21
+ * @returns 随机数
22
+ */
23
+ declare function random(min: number, max: number, integer?: boolean): number;
24
+ /**
25
+ * 限制数值范围
26
+ * @param num - 数字
27
+ * @param min - 最小值
28
+ * @param max - 最大值
29
+ * @returns 限制后的数字
30
+ */
31
+ declare function clamp(num: number, min: number, max: number): number;
32
+ /**
33
+ * 增强版四舍五入
34
+ * @param num - 数字
35
+ * @param decimals - 小数位数,默认为 0
36
+ * @returns 四舍五入后的数字
37
+ */
38
+ declare function round(num: number, decimals?: number): number;
39
+ /**
40
+ * 增强版向下取整
41
+ * @param num - 数字
42
+ * @param decimals - 小数位数,默认为 0
43
+ * @returns 向下取整后的数字
44
+ */
45
+ declare function floor(num: number, decimals?: number): number;
46
+ /**
47
+ * 增强版向上取整
48
+ * @param num - 数字
49
+ * @param decimals - 小数位数,默认为 0
50
+ * @returns 向上取整后的数字
51
+ */
52
+ declare function ceil(num: number, decimals?: number): number;
53
+ /**
54
+ * 保留小数位(增强版)
55
+ * @param num - 数字
56
+ * @param decimals - 小数位数
57
+ * @returns 格式化后的字符串
58
+ */
59
+ declare function toFixed(num: number, decimals: number): string;
60
+ /**
61
+ * 解析数字字符串
62
+ * @param str - 数字字符串
63
+ * @param defaultValue - 默认值,解析失败时返回
64
+ * @returns 解析后的数字
65
+ */
66
+ declare function parseNumber(str: string, defaultValue?: number): number;
67
+ /**
68
+ * 判断是否在范围内
69
+ * @param num - 数字
70
+ * @param min - 最小值
71
+ * @param max - 最大值
72
+ * @param inclusive - 是否包含边界,默认为 true
73
+ * @returns 是否在范围内
74
+ */
75
+ declare function isBetween(num: number, min: number, max: number, inclusive?: boolean): boolean;
76
+ /**
77
+ * 百分比计算
78
+ * @param value - 当前值(0-1之间的小数)或当前值(当提供total时)
79
+ * @param decimals - 小数位数,默认为 0(当value是0-1之间的小数时)或总值(当value是实际值时)
80
+ * @returns 百分比数字(当value是0-1之间的小数时)或百分比字符串(当提供total时)
81
+ */
82
+ declare function percent(value: number, decimals?: number): number;
83
+ declare function percent(value: number, total: number, decimals: number): string;
84
+ /**
85
+ * 货币格式化
86
+ * @param num - 数字
87
+ * @param currency - 货币符号,默认为 '¥'
88
+ * @param decimals - 小数位数,默认为 2
89
+ * @returns 格式化后的货币字符串
90
+ */
91
+ declare function formatCurrency(num: number, currency?: string, decimals?: number): string;
92
+ /**
93
+ * 字节格式化
94
+ * @param bytes - 字节数
95
+ * @param decimals - 小数位数,默认为 2
96
+ * @returns 格式化后的字节字符串
97
+ */
98
+ declare function formatBytes(bytes: number, decimals?: number): string;
99
+
100
+ export { ceil, clamp, floor, formatBytes, formatCurrency, formatNumber, isBetween, parseNumber, percent, random, round, toFixed };
package/dist/number.js ADDED
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var chunkMMR6XQNX_js = require('./chunk-MMR6XQNX.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "ceil", {
8
+ enumerable: true,
9
+ get: function () { return chunkMMR6XQNX_js.ceil; }
10
+ });
11
+ Object.defineProperty(exports, "clamp", {
12
+ enumerable: true,
13
+ get: function () { return chunkMMR6XQNX_js.clamp; }
14
+ });
15
+ Object.defineProperty(exports, "floor", {
16
+ enumerable: true,
17
+ get: function () { return chunkMMR6XQNX_js.floor; }
18
+ });
19
+ Object.defineProperty(exports, "formatBytes", {
20
+ enumerable: true,
21
+ get: function () { return chunkMMR6XQNX_js.formatBytes; }
22
+ });
23
+ Object.defineProperty(exports, "formatCurrency", {
24
+ enumerable: true,
25
+ get: function () { return chunkMMR6XQNX_js.formatCurrency; }
26
+ });
27
+ Object.defineProperty(exports, "formatNumber", {
28
+ enumerable: true,
29
+ get: function () { return chunkMMR6XQNX_js.formatNumber; }
30
+ });
31
+ Object.defineProperty(exports, "isBetween", {
32
+ enumerable: true,
33
+ get: function () { return chunkMMR6XQNX_js.isBetween; }
34
+ });
35
+ Object.defineProperty(exports, "parseNumber", {
36
+ enumerable: true,
37
+ get: function () { return chunkMMR6XQNX_js.parseNumber; }
38
+ });
39
+ Object.defineProperty(exports, "percent", {
40
+ enumerable: true,
41
+ get: function () { return chunkMMR6XQNX_js.percent; }
42
+ });
43
+ Object.defineProperty(exports, "random", {
44
+ enumerable: true,
45
+ get: function () { return chunkMMR6XQNX_js.random; }
46
+ });
47
+ Object.defineProperty(exports, "round", {
48
+ enumerable: true,
49
+ get: function () { return chunkMMR6XQNX_js.round; }
50
+ });
51
+ Object.defineProperty(exports, "toFixed", {
52
+ enumerable: true,
53
+ get: function () { return chunkMMR6XQNX_js.toFixed; }
54
+ });
55
+ //# sourceMappingURL=number.js.map
56
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"number.js"}
@@ -0,0 +1,3 @@
1
+ export { ceil, clamp, floor, formatBytes, formatCurrency, formatNumber, isBetween, parseNumber, percent, random, round, toFixed } from './chunk-ALDC6LRJ.mjs';
2
+ //# sourceMappingURL=number.mjs.map
3
+ //# sourceMappingURL=number.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"number.mjs"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * 对象工具函数
3
+ */
4
+ /**
5
+ * 深拷贝对象
6
+ * 支持 Date、Array、RegExp、Map、Set 等特殊类型
7
+ * @param obj - 输入对象
8
+ * @returns 深拷贝后的对象
9
+ */
10
+ declare function deepClone<T>(obj: T): T;
11
+ /**
12
+ * 对象合并
13
+ * @param target - 目标对象
14
+ * @param sources - 源对象数组
15
+ * @returns 合并后的对象
16
+ */
17
+ declare function merge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
18
+ /**
19
+ * 深合并对象
20
+ * @param target - 目标对象
21
+ * @param sources - 源对象数组
22
+ * @returns 深合并后的对象
23
+ */
24
+ declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
25
+ /**
26
+ * 获取对象嵌套属性值
27
+ * @param obj - 对象
28
+ * @param path - 属性路径,如 'a.b.c' 或 ['a', 'b', 'c']
29
+ * @param defaultValue - 默认值
30
+ * @returns 属性值
31
+ */
32
+ declare function get<T = unknown>(obj: Record<string, unknown>, path: string | string[], defaultValue?: T): T | undefined;
33
+ /**
34
+ * 设置嵌套属性值
35
+ * @param obj - 对象
36
+ * @param path - 属性路径,如 'a.b.c' 或 ['a', 'b', 'c']
37
+ * @param value - 要设置的值
38
+ * @returns 设置后的新对象(不修改原对象)
39
+ */
40
+ declare function set<T extends Record<string, unknown>>(obj: T, path: string | string[], value: unknown): T;
41
+ /**
42
+ * 选择指定属性
43
+ * @param obj - 对象
44
+ * @param keys - 要选择的属性键数组
45
+ * @returns 包含指定属性的新对象
46
+ */
47
+ declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
48
+ /**
49
+ * 排除指定属性
50
+ * @param obj - 对象
51
+ * @param keys - 要排除的属性键数组
52
+ * @returns 排除指定属性后的新对象
53
+ */
54
+ declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
55
+ /**
56
+ * 获取所有键(支持深度)
57
+ * @param obj - 对象
58
+ * @param deep - 是否深度获取,默认为 false
59
+ * @returns 键数组
60
+ */
61
+ declare function keys<T extends Record<string, unknown>>(obj: T, deep?: boolean): string[];
62
+ /**
63
+ * 获取所有值(支持深度)
64
+ * @param obj - 对象
65
+ * @param deep - 是否深度获取,默认为 false
66
+ * @returns 值数组
67
+ */
68
+ declare function values<T extends Record<string, unknown>>(obj: T, deep?: boolean): unknown[];
69
+ /**
70
+ * 键映射
71
+ * @param obj - 对象
72
+ * @param fn - 键转换函数
73
+ * @returns 键映射后的新对象
74
+ */
75
+ declare function mapKeys<T extends Record<string, unknown>>(obj: T, fn: (key: string, value: unknown) => string): Record<string, unknown>;
76
+ /**
77
+ * 值映射
78
+ * @param obj - 对象
79
+ * @param fn - 值转换函数
80
+ * @returns 值映射后的新对象
81
+ */
82
+ declare function mapValues<T extends Record<string, unknown>, R>(obj: T, fn: (value: unknown, key: string) => R): Record<string, R>;
83
+ /**
84
+ * 键值反转
85
+ * @param obj - 对象
86
+ * @returns 键值反转后的新对象
87
+ */
88
+ declare function invert<T extends Record<string, string | number>>(obj: T): Record<string, string>;
89
+ /**
90
+ * 设置默认值
91
+ * @param obj - 对象
92
+ * @param defaults - 默认值对象
93
+ * @returns 合并默认值后的新对象
94
+ */
95
+ declare function defaults<T extends Record<string, unknown>>(obj: Partial<T>, ...defaults: Partial<T>[]): T;
96
+ /**
97
+ * 判断对象是否为空
98
+ * @param obj - 对象
99
+ * @returns 是否为空
100
+ */
101
+ declare function isEmptyObject(obj: Record<string, unknown>): boolean;
102
+ /**
103
+ * 深度比较两个对象
104
+ * @param obj1 - 第一个对象
105
+ * @param obj2 - 第二个对象
106
+ * @returns 是否相等
107
+ */
108
+ declare function isEqual<T>(obj1: T, obj2: T): boolean;
109
+ /**
110
+ * 对象转换
111
+ * @param obj - 对象
112
+ * @param iteratee - 转换函数
113
+ * @param accumulator - 累加器,默认为空对象
114
+ * @returns 转换后的对象
115
+ */
116
+ declare function transform<T extends Record<string, unknown>, R extends Record<string, unknown>>(obj: T, iteratee: (result: R, value: unknown, key: string) => void, accumulator?: R): R;
117
+ /**
118
+ * 条件选择属性
119
+ * @param obj - 对象
120
+ * @param predicate - 条件函数
121
+ * @returns 满足条件的属性组成的新对象
122
+ */
123
+ declare function pickBy<T extends Record<string, unknown>>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
124
+ /**
125
+ * 条件排除属性
126
+ * @param obj - 对象
127
+ * @param predicate - 条件函数
128
+ * @returns 不满足条件的属性组成的新对象
129
+ */
130
+ declare function omitBy<T extends Record<string, unknown>>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
131
+
132
+ export { deepClone, deepMerge, defaults, get, invert, isEmptyObject, isEqual, keys, mapKeys, mapValues, merge, omit, omitBy, pick, pickBy, set, transform, values };