@hairy/utils 1.0.19 → 1.0.20

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 (3) hide show
  1. package/LICENSE +23 -23
  2. package/index.d.ts +193 -193
  3. package/package.json +5 -7
package/LICENSE CHANGED
@@ -1,23 +1,23 @@
1
- MIT License
2
-
3
- Copyright (c) 2019-PRESENT Anthony Fu<https://github.com/TuiMao233>
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.
22
-
23
-
1
+ MIT License
2
+
3
+ Copyright (c) 2019-PRESENT Anthony Fu<https://github.com/TuiMao233>
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.
22
+
23
+
package/index.d.ts CHANGED
@@ -1,208 +1,208 @@
1
- /**
2
- * 颜色混合器 - 仅支持 hex 颜色完整值
3
- * @param colorOne 颜色值
4
- * @param colorTwo 颜色值
5
- * @param ratio 根据 colorTwo 混合比例, 0~1 区间, 1 则是完全的 colorTwo
6
- * @returns 混合颜色
7
- */
8
- declare const colourBlend: (colorOne: string, colorTwo: string, ratio: number) => string;
9
- /**
10
- * 将 hex 颜色转成 rgb
11
- * @param hex
12
- * @param opacity
13
- * @returns rgba String
14
- */
15
- declare const hexToRgba: (hex: string, opacity: number) => {
16
- red: number;
17
- green: number;
18
- blue: number;
19
- rgba: string;
20
- };
21
- /**
22
- * 根据颜色融合出黑色与白色, 透明度色
23
- * @param color
24
- */
25
- declare const fuseThemeColor: (color: string) => {
26
- 'light-2': string;
27
- 'light-4': string;
28
- 'light-6': string;
29
- 'light-8': string;
30
- 'dark-2': string;
31
- 'dark-4': string;
32
- 'dark-6': string;
33
- 'dark-8': string;
34
- 'opacity-2': string;
35
- 'opacity-4': string;
36
- 'opacity-6': string;
37
- 'opacity-8': string;
1
+ /**
2
+ * 颜色混合器 - 仅支持 hex 颜色完整值
3
+ * @param colorOne 颜色值
4
+ * @param colorTwo 颜色值
5
+ * @param ratio 根据 colorTwo 混合比例, 0~1 区间, 1 则是完全的 colorTwo
6
+ * @returns 混合颜色
7
+ */
8
+ declare const colourBlend: (colorOne: string, colorTwo: string, ratio: number) => string;
9
+ /**
10
+ * 将 hex 颜色转成 rgb
11
+ * @param hex
12
+ * @param opacity
13
+ * @returns rgba String
14
+ */
15
+ declare const hexToRgba: (hex: string, opacity: number) => {
16
+ red: number;
17
+ green: number;
18
+ blue: number;
19
+ rgba: string;
20
+ };
21
+ /**
22
+ * 根据颜色融合出黑色与白色, 透明度色
23
+ * @param color
24
+ */
25
+ declare const fuseThemeColor: (color: string) => {
26
+ 'light-2': string;
27
+ 'light-4': string;
28
+ 'light-6': string;
29
+ 'light-8': string;
30
+ 'dark-2': string;
31
+ 'dark-4': string;
32
+ 'dark-6': string;
33
+ 'dark-8': string;
34
+ 'opacity-2': string;
35
+ 'opacity-4': string;
36
+ 'opacity-6': string;
37
+ 'opacity-8': string;
38
38
  };
39
39
 
40
- /**
41
- * 格式化剔除字符串代码字段
42
- * @param str 字符串
43
- * @returns 剔除字符串
44
- */
45
- declare const formatClearHtml: (string_: string) => string;
46
- /**
47
- * 格式化为价格(两位小数点)
48
- * @param value 传入字符
49
- */
50
- declare const formatPrice: (value: string) => string;
51
- /**
52
- * 格式化为正整数
53
- * @param value 传入字符
54
- */
55
- declare const formatInteger: (value: string) => string;
56
- /**
57
- * 格式化数字千位分隔符
58
- * @param number_ 数值
59
- * @param unit 单位
60
- */
61
- declare const formatThousandBitSeparator: (target: number | string, unit?: string) => string;
62
- /**
63
- * 时间戳格式化(秒)
64
- * @param timestamp 格式化时间戳(秒)
65
- * @param format 格式化时间格式
66
- * @returns 格式时间字符串
67
- */
68
- declare const formatUnix: (timestamp: number, format?: string) => string;
69
- /**
70
- * 隐藏手机号中间四位
71
- * @param phone 手机号
72
- */
73
- declare const formatCoverPhone: (phone: string) => string;
74
- /**
75
- * 数字位数不够时,进行前补零
76
- * @param num 数值
77
- * @param lh 长度
78
- */
79
- declare const prefixZero: (number_: number, lh?: number) => string;
80
- /**
81
- * 转换大写驼峰
82
- * @param str
83
- */
40
+ /**
41
+ * 格式化剔除字符串代码字段
42
+ * @param str 字符串
43
+ * @returns 剔除字符串
44
+ */
45
+ declare const formatClearHtml: (string_: string) => string;
46
+ /**
47
+ * 格式化为价格(两位小数点)
48
+ * @param value 传入字符
49
+ */
50
+ declare const formatPrice: (value: string) => string;
51
+ /**
52
+ * 格式化为正整数
53
+ * @param value 传入字符
54
+ */
55
+ declare const formatInteger: (value: string) => string;
56
+ /**
57
+ * 格式化数字千位分隔符
58
+ * @param number_ 数值
59
+ * @param unit 单位
60
+ */
61
+ declare const formatThousandBitSeparator: (target: number | string, unit?: string) => string;
62
+ /**
63
+ * 时间戳格式化(秒)
64
+ * @param timestamp 格式化时间戳(秒)
65
+ * @param format 格式化时间格式
66
+ * @returns 格式时间字符串
67
+ */
68
+ declare const formatUnix: (timestamp: number, format?: string) => string;
69
+ /**
70
+ * 隐藏手机号中间四位
71
+ * @param phone 手机号
72
+ */
73
+ declare const formatCoverPhone: (phone: string) => string;
74
+ /**
75
+ * 数字位数不够时,进行前补零
76
+ * @param num 数值
77
+ * @param lh 长度
78
+ */
79
+ declare const prefixZero: (number_: number, lh?: number) => string;
80
+ /**
81
+ * 转换大写驼峰
82
+ * @param str
83
+ */
84
84
  declare const capitalizeCamelCase: (string_: string) => string;
85
85
 
86
- declare const isBrowser: boolean;
87
- declare const isWeex: boolean;
88
- declare const weexPlatform: any;
89
- declare const UA: string | false;
90
- declare const isIE: boolean | "";
91
- declare const isIE9: boolean | "";
92
- declare const isIE11: boolean;
93
- declare const isEdge: boolean | "";
94
- declare const isAndroid: boolean;
95
- declare const isIOS: boolean;
96
- declare const isChrome: boolean | "";
97
- declare const isPhantomJS: boolean | "";
98
- declare const isFF: false | RegExpMatchArray | null;
99
- declare const isMobile: boolean;
100
- declare const isFormData: (value: any) => value is FormData;
86
+ declare const isBrowser: boolean;
87
+ declare const isWeex: boolean;
88
+ declare const weexPlatform: any;
89
+ declare const UA: string | false;
90
+ declare const isIE: boolean | "";
91
+ declare const isIE9: boolean | "";
92
+ declare const isIE11: boolean;
93
+ declare const isEdge: boolean | "";
94
+ declare const isAndroid: boolean;
95
+ declare const isIOS: boolean;
96
+ declare const isChrome: boolean | "";
97
+ declare const isPhantomJS: boolean | "";
98
+ declare const isFF: false | RegExpMatchArray | null;
99
+ declare const isMobile: boolean;
100
+ declare const isFormData: (value: any) => value is FormData;
101
101
  declare const isWindow: (value: any) => value is Window;
102
102
 
103
- /**
104
- * 将 formData 转换为 object
105
- * @param formData
106
- */
107
- declare const formDataToObject: (formData: FormData) => Record<string, string>;
108
- /**
109
- * 将 object 转换为 formData
110
- * @param object
111
- */
112
- declare const objectToFormData: (object: Record<string, string | number>) => FormData;
113
- /**
114
- * 过滤对象|数组中 filters 中的值
115
- * @param params
116
- * @param filters
117
- */
118
- declare const pickByParams: <T extends object>(params: T, filters: any[], deep?: boolean) => Partial<T>;
119
- /**
120
- * 对象扁平化处理
121
- * @param object 对象
122
- * @param deep 深度
123
- */
103
+ /**
104
+ * 将 formData 转换为 object
105
+ * @param formData
106
+ */
107
+ declare const formDataToObject: (formData: FormData) => Record<string, string>;
108
+ /**
109
+ * 将 object 转换为 formData
110
+ * @param object
111
+ */
112
+ declare const objectToFormData: (object: Record<string, string | number>) => FormData;
113
+ /**
114
+ * 过滤对象|数组中 filters 中的值
115
+ * @param params
116
+ * @param filters
117
+ */
118
+ declare const pickByParams: <T extends object>(params: T, filters: any[], deep?: boolean) => Partial<T>;
119
+ /**
120
+ * 对象扁平化处理
121
+ * @param object 对象
122
+ * @param deep 深度
123
+ */
124
124
  declare const objectFlat: (object: Record<string, any>, deep?: number) => Record<string, any>;
125
125
 
126
- declare type PlainObject = {
127
- [key: string]: any;
128
- };
129
- declare type LooseNumber = string | number;
130
- declare type Key = string | number | symbol;
131
- declare type DeepReadonly<T> = {
132
- readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
133
- };
134
- declare type DeepRequired<T> = {
135
- [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
136
- };
137
- declare type DeepPartial<T> = {
138
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
139
- };
140
- declare type DeepKeyof<T> = T extends object ? keyof T | DeepKeyof<T[keyof T]> : never;
141
- declare type DeepReplace<T, K = unknown, V = unknown> = {
142
- [P in keyof T]: K extends P ? V : DeepReplace<T[P], K, V>;
143
- };
144
- declare type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'children'> = {
145
- [P in L]?: string;
146
- } & {
147
- [P in V]?: LooseNumber;
148
- } & {
149
- [P in C]?: Option<L, V, C>[];
126
+ declare type PlainObject = {
127
+ [key: string]: any;
128
+ };
129
+ declare type LooseNumber = string | number;
130
+ declare type Key = string | number | symbol;
131
+ declare type DeepReadonly<T> = {
132
+ readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
133
+ };
134
+ declare type DeepRequired<T> = {
135
+ [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
136
+ };
137
+ declare type DeepPartial<T> = {
138
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
139
+ };
140
+ declare type DeepKeyof<T> = T extends object ? keyof T | DeepKeyof<T[keyof T]> : never;
141
+ declare type DeepReplace<T, K = unknown, V = unknown> = {
142
+ [P in keyof T]: K extends P ? V : DeepReplace<T[P], K, V>;
143
+ };
144
+ declare type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'children'> = {
145
+ [P in L]?: string;
146
+ } & {
147
+ [P in V]?: LooseNumber;
148
+ } & {
149
+ [P in C]?: Option<L, V, C>[];
150
150
  };
151
151
 
152
- /**
153
- * 如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上px单位
154
- * @param size 尺寸
155
- * @param unit 单元
156
- * @returns string
157
- */
158
- declare const analyUnit: (value: LooseNumber, unit?: string) => string;
159
- /** size 转换配置 */
160
- declare type AnalySizeOption = LooseNumber | [LooseNumber, LooseNumber] | {
161
- width: LooseNumber;
162
- height: LooseNumber;
163
- };
164
- /**
165
- * 将 size 转换为宽高
166
- * @param size { AnalySizeOption }
167
- * @returns
168
- */
169
- declare const analySize: (size: AnalySizeOption, unit?: string | undefined) => {
170
- width: string;
171
- height: string;
152
+ /**
153
+ * 如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上px单位
154
+ * @param size 尺寸
155
+ * @param unit 单元
156
+ * @returns string
157
+ */
158
+ declare const analyUnit: (value: LooseNumber, unit?: string) => string;
159
+ /** size 转换配置 */
160
+ declare type AnalySizeOption = LooseNumber | [LooseNumber, LooseNumber] | {
161
+ width: LooseNumber;
162
+ height: LooseNumber;
163
+ };
164
+ /**
165
+ * 将 size 转换为宽高
166
+ * @param size { AnalySizeOption }
167
+ * @returns
168
+ */
169
+ declare const analySize: (size: AnalySizeOption, unit?: string | undefined) => {
170
+ width: string;
171
+ height: string;
172
172
  };
173
173
 
174
- /**
175
- * 地址参数计算
176
- * @param url 传入url
177
- * @param params 请求参数
178
- * @returns 拼接url
179
- */
180
- declare const urlParamsAnaly: (url: string, params: Record<string, any>) => string;
181
- /**
182
- * 自定义 Promise 等待
183
- * @param code 等待时间
184
- */
185
- declare const awaitPromise: (ms?: number) => Promise<unknown>;
186
- /**
187
- * 生成递进的数组
188
- * @param start 开始数值
189
- * @param end 结束数值
190
- * @returns 递进的数组
191
- */
192
- declare const generateArray: (start: number, end: number) => number[];
193
- /** 空的方法 */
194
- declare const noop: () => void;
195
- /**
196
- * 获取数据类型
197
- * @param target 检测对象
198
- * @returns 返回字符串
199
- */
200
- declare const checkedTypeof: (target: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "regexp";
201
- /**
202
- * 不符合预期则弹出警告
203
- * @param condition
204
- * @param infos
205
- */
174
+ /**
175
+ * 地址参数计算
176
+ * @param url 传入url
177
+ * @param params 请求参数
178
+ * @returns 拼接url
179
+ */
180
+ declare const urlParamsAnaly: (url: string, params: Record<string, any>) => string;
181
+ /**
182
+ * 自定义 Promise 等待
183
+ * @param code 等待时间
184
+ */
185
+ declare const awaitPromise: (ms?: number) => Promise<unknown>;
186
+ /**
187
+ * 生成递进的数组
188
+ * @param start 开始数值
189
+ * @param end 结束数值
190
+ * @returns 递进的数组
191
+ */
192
+ declare const generateArray: (start: number, end: number) => number[];
193
+ /** 空的方法 */
194
+ declare const noop: () => void;
195
+ /**
196
+ * 获取数据类型
197
+ * @param target 检测对象
198
+ * @returns 返回字符串
199
+ */
200
+ declare const checkedTypeof: (target: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "regexp";
201
+ /**
202
+ * 不符合预期则弹出警告
203
+ * @param condition
204
+ * @param infos
205
+ */
206
206
  declare const assert: (condition: boolean, ...infos: any[]) => boolean;
207
207
 
208
208
  export { AnalySizeOption, DeepKeyof, DeepPartial, DeepReadonly, DeepReplace, DeepRequired, Key, LooseNumber, Option, PlainObject, UA, analySize, analyUnit, assert, awaitPromise, capitalizeCamelCase, checkedTypeof, colourBlend, formDataToObject, formatClearHtml, formatCoverPhone, formatInteger, formatPrice, formatThousandBitSeparator, formatUnix, fuseThemeColor, generateArray, hexToRgba, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isPhantomJS, isWeex, isWindow, noop, objectFlat, objectToFormData, pickByParams, prefixZero, urlParamsAnaly, weexPlatform };
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@hairy/utils",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "dayjs": "^1.10.6"
6
+ "dayjs": "^1.10.6",
7
+ "lodash": "^4"
7
8
  },
8
9
  "devDependencies": {
9
- "@types/lodash": "^4.14.171"
10
- },
11
- "peerDependencies": {
12
- "lodash": "^4.17.21"
10
+ "@types/lodash": "^4"
13
11
  },
14
12
  "main": "./index.cjs.js",
15
13
  "types": "./index.d.ts",
@@ -33,7 +31,7 @@
33
31
  },
34
32
  "./*": "./*"
35
33
  },
36
- "gitHead": "e52024f8c05853d0fe0b155df4f3beaed0ce7c6a",
34
+ "gitHead": "5ff534a17318b4e424c9509a0e3459d860a4aac1",
37
35
  "publishConfig": {
38
36
  "access": "public"
39
37
  }