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.
- package/README.md +183 -152
- package/dist/array/access.js +4 -5
- package/dist/array/chunk.js +1 -2
- package/dist/array/compact.js +1 -2
- package/dist/array/filterDuplicateValues.js +2 -3
- package/dist/array/flatten.js +2 -3
- package/dist/array/groupBy.js +1 -2
- package/dist/array/set-operations.js +3 -4
- package/dist/array/sortBy.js +1 -2
- package/dist/array/uniq.js +2 -3
- package/dist/async/index.js +3 -4
- package/dist/color/colorConvert.d.ts +64 -0
- package/dist/color/colorConvert.d.ts.map +1 -0
- package/dist/color/colorConvert.js +143 -0
- package/dist/color/colorValidate.d.ts +38 -0
- package/dist/color/colorValidate.d.ts.map +1 -0
- package/dist/color/colorValidate.js +81 -0
- package/dist/color/generateColors.d.ts +32 -0
- package/dist/color/generateColors.d.ts.map +1 -0
- package/dist/color/generateColors.js +143 -0
- package/dist/color/index.d.ts +7 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +22 -0
- package/dist/date/dateCalc.js +6 -7
- package/dist/date/dateCheck.js +6 -7
- package/dist/date/formatDate.js +1 -2
- package/dist/demo/colorDemo.d.ts +5 -0
- package/dist/demo/colorDemo.d.ts.map +1 -0
- package/dist/demo/colorDemo.js +34 -0
- package/dist/demo/index.js +6 -7
- package/dist/esm/color/colorConvert.d.ts +64 -0
- package/dist/esm/color/colorConvert.d.ts.map +1 -0
- package/dist/esm/color/colorConvert.js +135 -0
- package/dist/esm/color/colorValidate.d.ts +38 -0
- package/dist/esm/color/colorValidate.d.ts.map +1 -0
- package/dist/esm/color/colorValidate.js +74 -0
- package/dist/esm/color/generateColors.d.ts +32 -0
- package/dist/esm/color/generateColors.d.ts.map +1 -0
- package/dist/esm/color/generateColors.js +137 -0
- package/dist/esm/color/index.d.ts +7 -0
- package/dist/esm/color/index.d.ts.map +1 -0
- package/dist/esm/color/index.js +6 -0
- package/dist/esm/demo/colorDemo.d.ts +5 -0
- package/dist/esm/demo/colorDemo.d.ts.map +1 -0
- package/dist/esm/demo/colorDemo.js +32 -0
- package/dist/esm/demo/index.js +7 -8
- package/dist/esm/generDom/message.d.ts.map +1 -1
- package/dist/esm/generDom/message.js +111 -111
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/function/debounce.js +1 -2
- package/dist/function/once.js +1 -2
- package/dist/function/sleep.js +2 -2
- package/dist/function/throttle.js +1 -2
- package/dist/generDom/message.d.ts.map +1 -1
- package/dist/generDom/message.js +111 -111
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -10
- package/dist/mapToArray/convertToArray.js +1 -2
- package/dist/mapToArray/flattenTree.js +1 -2
- package/dist/number/math.js +5 -6
- package/dist/number/random.js +2 -3
- package/dist/number/range.js +2 -3
- package/dist/number/toFixed.js +1 -2
- package/dist/object/deepClone.js +1 -2
- package/dist/object/flattenObject.js +2 -3
- package/dist/object/get.js +1 -2
- package/dist/object/hasKey.js +6 -7
- package/dist/object/merge.js +1 -2
- package/dist/object/omit.js +1 -2
- package/dist/object/pick.js +1 -2
- package/dist/object/set.js +1 -2
- package/dist/string/camelCase.js +1 -2
- package/dist/string/capitalize.js +1 -2
- package/dist/string/kebabCase.js +1 -2
- package/dist/string/pascalCase.js +1 -2
- package/dist/string/randomString.js +3 -4
- package/dist/string/renderTemplate.js +1 -2
- package/dist/string/snakeCase.js +1 -2
- package/dist/string/toThousandsIntl.js +2 -3
- package/dist/string/trim.js +3 -4
- package/dist/string/truncate.js +1 -2
- package/dist/url/index.js +4 -5
- package/dist/utility/isEmpty.js +1 -2
- package/dist/utility/isType.js +15 -16
- package/dist/utility/uuid.js +3 -4
- package/dist/validate/index.js +8 -9
- package/package.json +120 -115
- package/dist/esm/mapToArray/mapToArray.d.ts +0 -10
- package/dist/esm/mapToArray/mapToArray.d.ts.map +0 -1
- package/dist/esm/mapToArray/mapToArray.js +0 -14
- package/dist/mapToArray/mapToArray.d.ts +0 -10
- package/dist/mapToArray/mapToArray.d.ts.map +0 -1
- 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.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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。
|
package/dist/array/access.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|
package/dist/array/chunk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunk =
|
|
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;
|
package/dist/array/compact.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compact =
|
|
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.
|
|
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;
|
package/dist/array/flatten.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|
package/dist/array/groupBy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.groupBy =
|
|
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.
|
|
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;
|
package/dist/array/sortBy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortBy =
|
|
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;
|
package/dist/array/uniq.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|
package/dist/async/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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"}
|