@bhsd/common 0.8.1 → 0.9.1
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 +17 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -0
- package/eslintrc.cjs +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LanguageServiceBase } from 'wikiparser-node/extensions/typings';
|
|
2
2
|
export declare const CDN = "https://testingcf.jsdelivr.net";
|
|
3
|
+
export type RegexGetter<T = string> = (s: T) => RegExp;
|
|
3
4
|
declare global {
|
|
4
5
|
const define: unknown;
|
|
5
6
|
}
|
|
@@ -55,3 +56,19 @@ export declare const getLSP: (obj: object, include?: boolean) => LanguageService
|
|
|
55
56
|
* @param style 内联样式
|
|
56
57
|
*/
|
|
57
58
|
export declare const sanitizeInlineStyle: (style: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* 刷新屏幕输出
|
|
61
|
+
* @param str 要输出的字符串
|
|
62
|
+
*/
|
|
63
|
+
export declare const refreshStdout: (str: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* 缓存生成的正则表达式
|
|
66
|
+
* @param f 生成正则表达式的函数
|
|
67
|
+
*/
|
|
68
|
+
export declare function getRegex(f: RegexGetter): RegexGetter;
|
|
69
|
+
export declare function getRegex<T extends object>(f: RegexGetter<T>): RegexGetter<T>;
|
|
70
|
+
/**
|
|
71
|
+
* 缓存生成的正则表达式
|
|
72
|
+
* @param f 生成正则表达式的函数
|
|
73
|
+
*/
|
|
74
|
+
export declare const getObjRegex: typeof getRegex;
|
package/dist/index.js
CHANGED
|
@@ -22,11 +22,14 @@ __export(index_exports, {
|
|
|
22
22
|
compareVersion: () => compareVersion,
|
|
23
23
|
decodeHTML: () => decodeHTML,
|
|
24
24
|
getLSP: () => getLSP,
|
|
25
|
+
getObjRegex: () => getObjRegex,
|
|
25
26
|
getObject: () => getObject,
|
|
27
|
+
getRegex: () => getRegex,
|
|
26
28
|
loadScript: () => loadScript,
|
|
27
29
|
normalizeTitle: () => normalizeTitle,
|
|
28
30
|
numToHex: () => numToHex,
|
|
29
31
|
rawurldecode: () => rawurldecode,
|
|
32
|
+
refreshStdout: () => refreshStdout,
|
|
30
33
|
sanitizeInlineStyle: () => sanitizeInlineStyle,
|
|
31
34
|
setObject: () => setObject,
|
|
32
35
|
splitColors: () => splitColors
|
|
@@ -123,3 +126,20 @@ const getLSP = (obj, include) => {
|
|
|
123
126
|
return lsp;
|
|
124
127
|
};
|
|
125
128
|
const sanitizeInlineStyle = (style) => style.replace(/[{}]/gu, (p) => p === "{" ? "{" : "}");
|
|
129
|
+
const refreshStdout = (str) => {
|
|
130
|
+
process.stdout.write(`\x1B[K\x1B[?7l${str}\x1B[?7h\r`);
|
|
131
|
+
};
|
|
132
|
+
function getRegex(f) {
|
|
133
|
+
return (s) => {
|
|
134
|
+
const regexp = new (typeof s === "string" ? Map : WeakMap)();
|
|
135
|
+
if (regexp.has(s)) {
|
|
136
|
+
const re2 = regexp.get(s);
|
|
137
|
+
re2.lastIndex = 0;
|
|
138
|
+
return re2;
|
|
139
|
+
}
|
|
140
|
+
const re = f(s);
|
|
141
|
+
regexp.set(s, re);
|
|
142
|
+
return re;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const getObjRegex = getRegex;
|
package/dist/index.mjs
CHANGED
|
@@ -89,16 +89,36 @@ const getLSP = (obj, include) => {
|
|
|
89
89
|
return lsp;
|
|
90
90
|
};
|
|
91
91
|
const sanitizeInlineStyle = (style) => style.replace(/[{}]/gu, (p) => p === "{" ? "{" : "}");
|
|
92
|
+
const refreshStdout = (str) => {
|
|
93
|
+
process.stdout.write(`\x1B[K\x1B[?7l${str}\x1B[?7h\r`);
|
|
94
|
+
};
|
|
95
|
+
function getRegex(f) {
|
|
96
|
+
return (s) => {
|
|
97
|
+
const regexp = new (typeof s === "string" ? Map : WeakMap)();
|
|
98
|
+
if (regexp.has(s)) {
|
|
99
|
+
const re2 = regexp.get(s);
|
|
100
|
+
re2.lastIndex = 0;
|
|
101
|
+
return re2;
|
|
102
|
+
}
|
|
103
|
+
const re = f(s);
|
|
104
|
+
regexp.set(s, re);
|
|
105
|
+
return re;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const getObjRegex = getRegex;
|
|
92
109
|
export {
|
|
93
110
|
CDN,
|
|
94
111
|
compareVersion,
|
|
95
112
|
decodeHTML,
|
|
96
113
|
getLSP,
|
|
114
|
+
getObjRegex,
|
|
97
115
|
getObject,
|
|
116
|
+
getRegex,
|
|
98
117
|
loadScript,
|
|
99
118
|
normalizeTitle,
|
|
100
119
|
numToHex,
|
|
101
120
|
rawurldecode,
|
|
121
|
+
refreshStdout,
|
|
102
122
|
sanitizeInlineStyle,
|
|
103
123
|
setObject,
|
|
104
124
|
splitColors
|
package/eslintrc.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bhsd/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Bhsd",
|
|
6
6
|
"files": [
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"mocha": "^11.1.0",
|
|
64
64
|
"stylelint": "^16.14.1",
|
|
65
65
|
"typescript": "^5.7.3",
|
|
66
|
-
"wikiparser-node": "^1.18.
|
|
66
|
+
"wikiparser-node": "^1.18.3"
|
|
67
67
|
}
|
|
68
68
|
}
|