jz-toolkit 1.1.9 → 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 (96) hide show
  1. package/README.md +183 -152
  2. package/dist/array/access.js +4 -5
  3. package/dist/array/chunk.js +1 -2
  4. package/dist/array/compact.js +1 -2
  5. package/dist/array/filterDuplicateValues.js +2 -3
  6. package/dist/array/flatten.js +2 -3
  7. package/dist/array/groupBy.js +1 -2
  8. package/dist/array/set-operations.js +3 -4
  9. package/dist/array/sortBy.js +1 -2
  10. package/dist/array/uniq.js +2 -3
  11. package/dist/async/index.js +3 -4
  12. package/dist/color/colorConvert.d.ts +64 -0
  13. package/dist/color/colorConvert.d.ts.map +1 -0
  14. package/dist/color/colorConvert.js +143 -0
  15. package/dist/color/colorValidate.d.ts +38 -0
  16. package/dist/color/colorValidate.d.ts.map +1 -0
  17. package/dist/color/colorValidate.js +81 -0
  18. package/dist/color/generateColors.d.ts +32 -0
  19. package/dist/color/generateColors.d.ts.map +1 -0
  20. package/dist/color/generateColors.js +143 -0
  21. package/dist/color/index.d.ts +7 -0
  22. package/dist/color/index.d.ts.map +1 -0
  23. package/dist/color/index.js +22 -0
  24. package/dist/date/dateCalc.js +6 -7
  25. package/dist/date/dateCheck.js +6 -7
  26. package/dist/date/formatDate.js +1 -2
  27. package/dist/demo/colorDemo.d.ts +5 -0
  28. package/dist/demo/colorDemo.d.ts.map +1 -0
  29. package/dist/demo/colorDemo.js +34 -0
  30. package/dist/demo/index.js +6 -7
  31. package/dist/esm/color/colorConvert.d.ts +64 -0
  32. package/dist/esm/color/colorConvert.d.ts.map +1 -0
  33. package/dist/esm/color/colorConvert.js +135 -0
  34. package/dist/esm/color/colorValidate.d.ts +38 -0
  35. package/dist/esm/color/colorValidate.d.ts.map +1 -0
  36. package/dist/esm/color/colorValidate.js +74 -0
  37. package/dist/esm/color/generateColors.d.ts +32 -0
  38. package/dist/esm/color/generateColors.d.ts.map +1 -0
  39. package/dist/esm/color/generateColors.js +137 -0
  40. package/dist/esm/color/index.d.ts +7 -0
  41. package/dist/esm/color/index.d.ts.map +1 -0
  42. package/dist/esm/color/index.js +6 -0
  43. package/dist/esm/demo/colorDemo.d.ts +5 -0
  44. package/dist/esm/demo/colorDemo.d.ts.map +1 -0
  45. package/dist/esm/demo/colorDemo.js +32 -0
  46. package/dist/esm/demo/index.js +7 -8
  47. package/dist/esm/generDom/message.d.ts.map +1 -1
  48. package/dist/esm/generDom/message.js +111 -111
  49. package/dist/esm/index.d.ts +2 -0
  50. package/dist/esm/index.d.ts.map +1 -1
  51. package/dist/esm/index.js +4 -0
  52. package/dist/function/debounce.js +1 -2
  53. package/dist/function/once.js +1 -2
  54. package/dist/function/sleep.js +2 -2
  55. package/dist/function/throttle.js +1 -2
  56. package/dist/generDom/message.d.ts.map +1 -1
  57. package/dist/generDom/message.js +111 -111
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +34 -10
  61. package/dist/mapToArray/convertToArray.js +1 -2
  62. package/dist/mapToArray/flattenTree.js +1 -2
  63. package/dist/number/math.js +5 -6
  64. package/dist/number/random.js +2 -3
  65. package/dist/number/range.js +2 -3
  66. package/dist/number/toFixed.js +1 -2
  67. package/dist/object/deepClone.js +1 -2
  68. package/dist/object/flattenObject.js +2 -3
  69. package/dist/object/get.js +1 -2
  70. package/dist/object/hasKey.js +6 -7
  71. package/dist/object/merge.js +1 -2
  72. package/dist/object/omit.js +1 -2
  73. package/dist/object/pick.js +1 -2
  74. package/dist/object/set.js +1 -2
  75. package/dist/string/camelCase.js +1 -2
  76. package/dist/string/capitalize.js +1 -2
  77. package/dist/string/kebabCase.js +1 -2
  78. package/dist/string/pascalCase.js +1 -2
  79. package/dist/string/randomString.js +3 -4
  80. package/dist/string/renderTemplate.js +1 -2
  81. package/dist/string/snakeCase.js +1 -2
  82. package/dist/string/toThousandsIntl.js +2 -3
  83. package/dist/string/trim.js +3 -4
  84. package/dist/string/truncate.js +1 -2
  85. package/dist/url/index.js +4 -5
  86. package/dist/utility/isEmpty.js +1 -2
  87. package/dist/utility/isType.js +15 -16
  88. package/dist/utility/uuid.js +3 -4
  89. package/dist/validate/index.js +8 -9
  90. package/package.json +120 -115
  91. package/dist/esm/mapToArray/mapToArray.d.ts +0 -10
  92. package/dist/esm/mapToArray/mapToArray.d.ts.map +0 -1
  93. package/dist/esm/mapToArray/mapToArray.js +0 -14
  94. package/dist/mapToArray/mapToArray.d.ts +0 -10
  95. package/dist/mapToArray/mapToArray.d.ts.map +0 -1
  96. package/dist/mapToArray/mapToArray.js +0 -18
package/README.md CHANGED
@@ -1,152 +1,183 @@
1
- # jz-toolkit
2
-
3
- 🚀 一个轻量级、功能丰富的 JavaScript/TypeScript 工具库。
4
-
5
- #### 🆕 最近更新
6
-
7
- ##### v1.1.9
8
- - 新增 `renderTemplate()` - 字符串模板替换函数,支持灵活的变量替换
9
-
10
- ```typescript
11
- import { renderTemplate } from "jz-toolkit";
12
-
13
- const result = renderTemplate(
14
- { name: "张三", money: 100.50 },
15
- "你好, {{name}}! 你的余额是 {{money}} 元。"
16
- );
17
- // 返回: "你好, 张三! 你的余额是 100.50 元。"
18
- ```
19
-
20
- ##### v1.1.8
21
- - 新增 `toThousandsIntl()` - 国际化数字千分位格式化函数,支持多地区格式
22
- - 新增 `toThousands()` - 常规数字千分位格式化函数
23
-
24
- ```typescript
25
- import { toThousandsIntl, toThousands } from "jz-toolkit";
26
-
27
- toThousandsIntl(1234567.89, "zh-CN"); // '1,234,567.89'
28
- toThousandsIntl(1234567.89, "de-DE"); // '1.234.567,89'
29
- toThousands(1234567.89); // '1,234,567.89'
30
- ```
31
-
32
- ## 特点
33
-
34
- ✨ **类型安全** - 使用 TypeScript 编写,提供完整的类型定义
35
-
36
- 📦 **模块化** - 支持按需导入,减少打包体积
37
-
38
- **高性能** - 精心优化的实现
39
-
40
- 🔧 **易于扩展** - 清晰的项目结构,易于添加新功能
41
-
42
- 📚 **良好文档** - 每个函数都有详细的文档和示例
43
-
44
- ## 安装
45
-
46
- ```bash
47
- npm i jz-toolkit
48
- ```
49
-
50
- ## 官方文档地址 - 更多Api在文档查阅
51
-
52
- http://172.81.245.148:8098/api/utils.html
53
-
54
- ## 快速开始
55
-
56
- ## 聊天群
57
-
58
- <img src="./assets/2871763863632_.pic.jpg" alt="聊天群" width="200">
59
-
60
- ### 完整导入
61
-
62
- ```typescript
63
- import * as _ from "jz-toolkit";
64
-
65
- _.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
66
- _.capitalize("hello"); // 'Hello'
67
- ```
68
-
69
- ### 按需导入
70
-
71
- ```typescript
72
- import { chunk, capitalize } from "jz-toolkit";
73
-
74
- chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
75
- capitalize("hello"); // 'Hello'
76
- ```
77
-
78
- ### 模块导入
79
-
80
- ```typescript
81
- import * as array from "jz-toolkit/array";
82
- import * as object from "jz-toolkit/object";
83
- import * as string from "jz-toolkit/string";
84
-
85
- array.chunk([1, 2, 3, 4], 2);
86
- object.pick({ a: 1, b: 2 }, ["a"]);
87
- string.capitalize("world");
88
- ```
89
-
90
- ## 开发
91
-
92
- ### 安装依赖
93
-
94
- ```bash
95
- npm install
96
- ```
97
-
98
- ### 构建
99
-
100
- ```bash
101
- npm run build
102
- ```
103
-
104
- ### 开发模式(监视文件变化)
105
-
106
- ```bash
107
- npm run dev
108
- ```
109
-
110
- ### 运行测试
111
-
112
- ```bash
113
- npm test
114
- ```
115
-
116
- ### 查看测试覆盖率
117
-
118
- ```bash
119
- npm run test:coverage
120
- ```
121
-
122
- ### 代码格式化
123
-
124
- ```bash
125
- npm run format
126
- ```
127
-
128
- ### Linting
129
-
130
- ```bash
131
- npm run lint
132
- ```
133
-
134
- ## 项目结构
135
-
136
- ```
137
- src/
138
- ├── index.ts # 主入口
139
- ├── types/ # 类型定义
140
- ├── array/ # 数组模块
141
- ├── object/ # 对象模块
142
- ├── string/ # 字符串模块
143
- └── utility/ # 工具函数模块
144
- ```
145
-
146
- ## 许可证
147
-
148
- MIT
149
-
150
- ## 贡献
151
-
152
- 欢迎贡献!请提交 PR 或 Issue。
1
+ # jz-toolkit
2
+
3
+ 🚀 一个轻量级、功能丰富的 JavaScript/TypeScript 工具库。
4
+
5
+ #### 🆕 最近更新
6
+
7
+ ##### v1.2.0
8
+
9
+ - 新增 `color` 模块 - 颜色工具函数集合
10
+ - 新增 `generateColors()` - 生成指定数量的随机十六进制颜色
11
+ - 新增 `generateRandomColor()` - 生成单个随机十六进制颜色
12
+ - 新增 `generateHarmoniousColors()` - 生成基于HSL的和谐色彩组合
13
+ - 新增 `generateGradientColors()` - 生成渐变色彩组合
14
+ - 新增 `hexToRgb()` - 将十六进制颜色转换为RGB格式
15
+ - 新增 `rgbToHex()` - 将RGB颜色转换为十六进制格式
16
+ - 新增 `hslToHex()` - 将HSL颜色转换为十六进制格式
17
+ - 新增 `hexToHsl()` - 将十六进制颜色转换为HSL格式
18
+ - 新增颜色验证函数:`isValidHex()`, `isValidRgb()`, `isValidHsl()`
19
+
20
+ ```typescript
21
+ import { generateColors, hexToRgb, generateHarmoniousColors } from "jz-toolkit";
22
+
23
+ // 生成8个随机颜色
24
+ const colors = generateColors(8);
25
+ // 返回: ['#FF5733', '#33FF57', '#5733FF', ...]
26
+
27
+ // 十六进制转RGB
28
+ const rgb = hexToRgb("#FF5733");
29
+ // 返回: { r: 255, g: 87, b: 51 }
30
+
31
+ // 生成和谐色彩组合
32
+ const harmoniousColors = generateHarmoniousColors(120, 6, 70, 50);
33
+ // 返回: ['#26D926', '#26D9D9', '#2626D9', ...]
34
+ ```
35
+
36
+ ##### v1.1.9
37
+
38
+ - 新增 `renderTemplate()` - 字符串模板替换函数,支持灵活的变量替换
39
+
40
+ ```typescript
41
+ import { renderTemplate } from "jz-toolkit";
42
+
43
+ const result = renderTemplate(
44
+ { name: "张三", money: 100.5 },
45
+ "你好, {{name}}! 你的余额是 {{money}} 元。",
46
+ );
47
+ // 返回: "你好, 张三! 你的余额是 100.50 元。"
48
+ ```
49
+
50
+ ##### v1.1.8
51
+
52
+ - 新增 `toThousandsIntl()` - 国际化数字千分位格式化函数,支持多地区格式
53
+ - 新增 `toThousands()` - 常规数字千分位格式化函数
54
+
55
+ ```typescript
56
+ import { toThousandsIntl, toThousands } from "jz-toolkit";
57
+
58
+ toThousandsIntl(1234567.89, "zh-CN"); // '1,234,567.89'
59
+ toThousandsIntl(1234567.89, "de-DE"); // '1.234.567,89'
60
+ toThousands(1234567.89); // '1,234,567.89'
61
+ ```
62
+
63
+ ## 特点
64
+
65
+ **类型安全** - 使用 TypeScript 编写,提供完整的类型定义
66
+
67
+ 📦 **模块化** - 支持按需导入,减少打包体积
68
+
69
+ **高性能** - 精心优化的实现
70
+
71
+ 🔧 **易于扩展** - 清晰的项目结构,易于添加新功能
72
+
73
+ 📚 **良好文档** - 每个函数都有详细的文档和示例
74
+
75
+ ## 安装
76
+
77
+ ```bash
78
+ npm i jz-toolkit
79
+ ```
80
+
81
+ ## 官方文档地址 - 更多Api在文档查阅
82
+
83
+ http://172.81.245.148:8098/api/utils.html
84
+
85
+ ## 快速开始
86
+
87
+ ## 聊天群
88
+
89
+ <img src="./assets/2871763863632_.pic.jpg" alt="聊天群" width="200">
90
+
91
+ ### 完整导入
92
+
93
+ ```typescript
94
+ import * as _ from "jz-toolkit";
95
+
96
+ _.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
97
+ _.capitalize("hello"); // 'Hello'
98
+ ```
99
+
100
+ ### 按需导入
101
+
102
+ ```typescript
103
+ import { chunk, capitalize } from "jz-toolkit";
104
+
105
+ chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
106
+ capitalize("hello"); // 'Hello'
107
+ ```
108
+
109
+ ### 模块导入
110
+
111
+ ```typescript
112
+ import * as array from "jz-toolkit/array";
113
+ import * as object from "jz-toolkit/object";
114
+ import * as string from "jz-toolkit/string";
115
+
116
+ array.chunk([1, 2, 3, 4], 2);
117
+ object.pick({ a: 1, b: 2 }, ["a"]);
118
+ string.capitalize("world");
119
+ ```
120
+
121
+ ## 开发
122
+
123
+ ### 安装依赖
124
+
125
+ ```bash
126
+ npm install
127
+ ```
128
+
129
+ ### 构建
130
+
131
+ ```bash
132
+ npm run build
133
+ ```
134
+
135
+ ### 开发模式(监视文件变化)
136
+
137
+ ```bash
138
+ npm run dev
139
+ ```
140
+
141
+ ### 运行测试
142
+
143
+ ```bash
144
+ npm test
145
+ ```
146
+
147
+ ### 查看测试覆盖率
148
+
149
+ ```bash
150
+ npm run test:coverage
151
+ ```
152
+
153
+ ### 代码格式化
154
+
155
+ ```bash
156
+ npm run format
157
+ ```
158
+
159
+ ### Linting
160
+
161
+ ```bash
162
+ npm run lint
163
+ ```
164
+
165
+ ## 项目结构
166
+
167
+ ```
168
+ src/
169
+ ├── index.ts # 主入口
170
+ ├── types/ # 类型定义
171
+ ├── array/ # 数组模块
172
+ ├── object/ # 对象模块
173
+ ├── string/ # 字符串模块
174
+ └── utility/ # 工具函数模块
175
+ ```
176
+
177
+ ## 许可证
178
+
179
+ MIT
180
+
181
+ ## 贡献
182
+
183
+ 欢迎贡献!请提交 PR 或 Issue。
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.takeRight = exports.take = exports.last = exports.first = void 0;
3
+ exports.first = first;
4
+ exports.last = last;
5
+ exports.take = take;
6
+ exports.takeRight = takeRight;
4
7
  /**
5
8
  * 获取数组的第一个元素
6
9
  * @param array 输入数组
@@ -13,7 +16,6 @@ exports.takeRight = exports.take = exports.last = exports.first = void 0;
13
16
  function first(array) {
14
17
  return array[0];
15
18
  }
16
- exports.first = first;
17
19
  /**
18
20
  * 获取数组的最后一个元素
19
21
  * @param array 输入数组
@@ -26,7 +28,6 @@ exports.first = first;
26
28
  function last(array) {
27
29
  return array[array.length - 1];
28
30
  }
29
- exports.last = last;
30
31
  /**
31
32
  * 获取数组的前n个元素
32
33
  * @param array 输入数组
@@ -39,7 +40,6 @@ exports.last = last;
39
40
  function take(array, n = 1) {
40
41
  return array.slice(0, n);
41
42
  }
42
- exports.take = take;
43
43
  /**
44
44
  * 获取数组的后n个元素
45
45
  * @param array 输入数组
@@ -52,4 +52,3 @@ exports.take = take;
52
52
  function takeRight(array, n = 1) {
53
53
  return n === 0 ? [] : array.slice(-n);
54
54
  }
55
- exports.takeRight = takeRight;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chunk = void 0;
3
+ exports.chunk = chunk;
4
4
  /**
5
5
  * 将数组分成指定大小的块
6
6
  * @param array 输入数组
@@ -21,4 +21,3 @@ function chunk(array, size) {
21
21
  }
22
22
  return result;
23
23
  }
24
- exports.chunk = chunk;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compact = void 0;
3
+ exports.compact = compact;
4
4
  /**
5
5
  * 移除数组中的虚值(false、null、0、""、undefined 和 NaN)
6
6
  * @param array 输入数组
@@ -13,4 +13,3 @@ exports.compact = void 0;
13
13
  function compact(array) {
14
14
  return array.filter((item) => Boolean(item));
15
15
  }
16
- exports.compact = compact;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterArrayAttr = exports.filterDuplicateValues = void 0;
3
+ exports.filterDuplicateValues = filterDuplicateValues;
4
+ exports.filterArrayAttr = filterArrayAttr;
4
5
  /**
5
6
  * Filters duplicate values from an array, keeping only unique items.
6
7
  * For objects, duplicates are determined by the key returned by the iteratee function.
@@ -33,7 +34,6 @@ function filterDuplicateValues(array, iteratee) {
33
34
  }
34
35
  return result;
35
36
  }
36
- exports.filterDuplicateValues = filterDuplicateValues;
37
37
  /**
38
38
  *
39
39
  * @param array - The array to filter.
@@ -46,4 +46,3 @@ function filterArrayAttr(array, extendParams) {
46
46
  const res = array.filter((item) => item[extendParams.key] === extendParams.value);
47
47
  return res;
48
48
  }
49
- exports.filterArrayAttr = filterArrayAttr;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flattenDeep = exports.flatten = void 0;
3
+ exports.flatten = flatten;
4
+ exports.flattenDeep = flattenDeep;
4
5
  /**
5
6
  * 数组扁平化
6
7
  * @param array 输入数组
@@ -26,7 +27,6 @@ function flatten(array, depth = 1) {
26
27
  return acc;
27
28
  }, []);
28
29
  }
29
- exports.flatten = flatten;
30
30
  /**
31
31
  * 深度扁平化数组(扁平化所有层级)
32
32
  * @param array 输入数组
@@ -38,4 +38,3 @@ exports.flatten = flatten;
38
38
  function flattenDeep(array) {
39
39
  return flatten(array, Infinity);
40
40
  }
41
- exports.flattenDeep = flattenDeep;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupBy = void 0;
3
+ exports.groupBy = groupBy;
4
4
  /**
5
5
  * 按指定属性或函数对数组进行分组
6
6
  * @param array 输入数组
@@ -26,4 +26,3 @@ function groupBy(array, iteratee) {
26
26
  return result;
27
27
  }, {});
28
28
  }
29
- exports.groupBy = groupBy;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.union = exports.difference = exports.intersection = void 0;
3
+ exports.intersection = intersection;
4
+ exports.difference = difference;
5
+ exports.union = union;
4
6
  /**
5
7
  * 返回两个数组的交集
6
8
  * @param arr1 第一个数组
@@ -14,7 +16,6 @@ function intersection(arr1, arr2) {
14
16
  const set2 = new Set(arr2);
15
17
  return arr1.filter((item) => set2.has(item));
16
18
  }
17
- exports.intersection = intersection;
18
19
  /**
19
20
  * 返回第一个数组与第二个数组的差集
20
21
  * @param arr1 第一个数组
@@ -28,7 +29,6 @@ function difference(arr1, arr2) {
28
29
  const set2 = new Set(arr2);
29
30
  return arr1.filter((item) => !set2.has(item));
30
31
  }
31
- exports.difference = difference;
32
32
  /**
33
33
  * 返回多个数组的并集
34
34
  * @param arrays 多个数组
@@ -40,4 +40,3 @@ exports.difference = difference;
40
40
  function union(...arrays) {
41
41
  return Array.from(new Set(arrays.flat()));
42
42
  }
43
- exports.union = union;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortBy = void 0;
3
+ exports.sortBy = sortBy;
4
4
  /**
5
5
  * 按指定属性或函数对数组进行排序
6
6
  * @param array 输入数组
@@ -25,4 +25,3 @@ function sortBy(array, iteratee) {
25
25
  return 0;
26
26
  });
27
27
  }
28
- exports.sortBy = sortBy;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniqBy = exports.uniq = void 0;
3
+ exports.uniq = uniq;
4
+ exports.uniqBy = uniqBy;
4
5
  /**
5
6
  * 数组去重
6
7
  * @param array 输入数组
@@ -13,7 +14,6 @@ exports.uniqBy = exports.uniq = void 0;
13
14
  function uniq(array) {
14
15
  return Array.from(new Set(array));
15
16
  }
16
- exports.uniq = uniq;
17
17
  /**
18
18
  * 根据迭代器函数进行去重
19
19
  * @param array 输入数组
@@ -34,4 +34,3 @@ function uniqBy(array, iteratee) {
34
34
  return true;
35
35
  });
36
36
  }
37
- exports.uniqBy = uniqBy;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promiseAllWithLimit = exports.timeout = exports.retry = void 0;
3
+ exports.retry = retry;
4
+ exports.timeout = timeout;
5
+ exports.promiseAllWithLimit = promiseAllWithLimit;
4
6
  /**
5
7
  * 重试执行异步函数
6
8
  * @param fn 要重试的异步函数
@@ -26,7 +28,6 @@ async function retry(fn, times = 3, interval = 1000) {
26
28
  }
27
29
  throw lastError || new Error("Retry failed");
28
30
  }
29
- exports.retry = retry;
30
31
  /**
31
32
  * 超时控制
32
33
  * @param promise 要执行的Promise
@@ -53,7 +54,6 @@ function timeout(promise, ms, errorMessage = "Operation timed out") {
53
54
  });
54
55
  });
55
56
  }
56
- exports.timeout = timeout;
57
57
  /**
58
58
  * 并发控制的Promise.all
59
59
  * @param tasks 任务函数数组
@@ -89,4 +89,3 @@ async function promiseAllWithLimit(tasks, limit) {
89
89
  await Promise.all(executing);
90
90
  return results;
91
91
  }
92
- exports.promiseAllWithLimit = promiseAllWithLimit;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 颜色格式转换工具
3
+ */
4
+ /**
5
+ * 十六进制转RGB
6
+ * @param hex 十六进制颜色字符串,如 "#FF5733" 或 "FF5733"
7
+ * @returns RGB对象 {r, g, b} 或 null
8
+ */
9
+ export declare function hexToRgb(hex: string): {
10
+ r: number;
11
+ g: number;
12
+ b: number;
13
+ } | null;
14
+ /**
15
+ * RGB转十六进制
16
+ * @param r 红色值 (0-255)
17
+ * @param g 绿色值 (0-255)
18
+ * @param b 蓝色值 (0-255)
19
+ * @returns 十六进制颜色字符串
20
+ */
21
+ export declare function rgbToHex(r: number, g: number, b: number): string;
22
+ /**
23
+ * 十六进制转HSL
24
+ * @param hex 十六进制颜色字符串
25
+ * @returns HSL对象 {h, s, l} 或 null
26
+ */
27
+ export declare function hexToHsl(hex: string): {
28
+ h: number;
29
+ s: number;
30
+ l: number;
31
+ } | null;
32
+ /**
33
+ * HSL转十六进制
34
+ * @param h 色相 (0-360)
35
+ * @param s 饱和度 (0-100)
36
+ * @param l 亮度 (0-100)
37
+ * @returns 十六进制颜色字符串
38
+ */
39
+ export declare function hslToHex(h: number, s: number, l: number): string;
40
+ /**
41
+ * RGB转HSL
42
+ * @param r 红色值 (0-255)
43
+ * @param g 绿色值 (0-255)
44
+ * @param b 蓝色值 (0-255)
45
+ * @returns HSL对象 {h, s, l}
46
+ */
47
+ export declare function rgbToHsl(r: number, g: number, b: number): {
48
+ h: number;
49
+ s: number;
50
+ l: number;
51
+ };
52
+ /**
53
+ * HSL转RGB
54
+ * @param h 色相 (0-360)
55
+ * @param s 饱和度 (0-100)
56
+ * @param l 亮度 (0-100)
57
+ * @returns RGB对象 {r, g, b}
58
+ */
59
+ export declare function hslToRgb(h: number, s: number, l: number): {
60
+ r: number;
61
+ g: number;
62
+ b: number;
63
+ };
64
+ //# sourceMappingURL=colorConvert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorConvert.d.ts","sourceRoot":"","sources":["../../src/color/colorConvert.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAchF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAKhF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CA4B7F;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CA+B7F"}