@bhsd/common 0.4.3 → 0.4.4
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/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export declare const rawurldecode: (str: string) => string;
|
|
|
12
12
|
* @param title 标题
|
|
13
13
|
*/
|
|
14
14
|
export declare const normalizeTitle: (title: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* 将0~1之间的数字转换为十六进制
|
|
17
|
+
* @param d 0~1之间的数字
|
|
18
|
+
*/
|
|
19
|
+
export declare const numToHex: (d: number) => string;
|
|
15
20
|
/**
|
|
16
21
|
* 包含颜色时断开字符串
|
|
17
22
|
* @param str 字符串
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(src_exports, {
|
|
|
22
22
|
getObject: () => getObject,
|
|
23
23
|
loadScript: () => loadScript,
|
|
24
24
|
normalizeTitle: () => normalizeTitle,
|
|
25
|
+
numToHex: () => numToHex,
|
|
25
26
|
parseVersion: () => parseVersion,
|
|
26
27
|
rawurldecode: () => rawurldecode,
|
|
27
28
|
setObject: () => setObject,
|
|
@@ -43,6 +44,7 @@ const normalizeTitle = (title) => {
|
|
|
43
44
|
span.innerHTML = decoded;
|
|
44
45
|
return span.textContent;
|
|
45
46
|
};
|
|
47
|
+
const numToHex = (d) => Math.round(d * 255).toString(16).padStart(2, "0");
|
|
46
48
|
const splitColors = (str, hsl = true) => {
|
|
47
49
|
const pieces = [], re = hsl ? reFull : reRGB;
|
|
48
50
|
re.lastIndex = 0;
|