@bhsd/common 0.8.1 → 0.9.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/dist/index.d.ts +16 -0
- package/dist/index.js +28 -0
- package/dist/index.mjs +28 -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,18 @@ 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 const getRegex: (f: RegexGetter) => RegexGetter;
|
|
69
|
+
/**
|
|
70
|
+
* 缓存生成的正则表达式
|
|
71
|
+
* @param f 生成正则表达式的函数
|
|
72
|
+
*/
|
|
73
|
+
export declare const getObjRegex: <T extends object>(f: RegexGetter<T>) => RegexGetter<T>;
|
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,28 @@ 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
|
+
const getRegex = (f) => (s) => {
|
|
133
|
+
const regexp = /* @__PURE__ */ new Map();
|
|
134
|
+
if (regexp.has(s)) {
|
|
135
|
+
const re2 = regexp.get(s);
|
|
136
|
+
re2.lastIndex = 0;
|
|
137
|
+
return re2;
|
|
138
|
+
}
|
|
139
|
+
const re = f(s);
|
|
140
|
+
regexp.set(s, re);
|
|
141
|
+
return re;
|
|
142
|
+
};
|
|
143
|
+
const getObjRegex = (f) => (s) => {
|
|
144
|
+
const regexp = /* @__PURE__ */ new WeakMap();
|
|
145
|
+
if (regexp.has(s)) {
|
|
146
|
+
const re2 = regexp.get(s);
|
|
147
|
+
re2.lastIndex = 0;
|
|
148
|
+
return re2;
|
|
149
|
+
}
|
|
150
|
+
const re = f(s);
|
|
151
|
+
regexp.set(s, re);
|
|
152
|
+
return re;
|
|
153
|
+
};
|
package/dist/index.mjs
CHANGED
|
@@ -89,16 +89,44 @@ 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
|
+
const getRegex = (f) => (s) => {
|
|
96
|
+
const regexp = /* @__PURE__ */ new Map();
|
|
97
|
+
if (regexp.has(s)) {
|
|
98
|
+
const re2 = regexp.get(s);
|
|
99
|
+
re2.lastIndex = 0;
|
|
100
|
+
return re2;
|
|
101
|
+
}
|
|
102
|
+
const re = f(s);
|
|
103
|
+
regexp.set(s, re);
|
|
104
|
+
return re;
|
|
105
|
+
};
|
|
106
|
+
const getObjRegex = (f) => (s) => {
|
|
107
|
+
const regexp = /* @__PURE__ */ new WeakMap();
|
|
108
|
+
if (regexp.has(s)) {
|
|
109
|
+
const re2 = regexp.get(s);
|
|
110
|
+
re2.lastIndex = 0;
|
|
111
|
+
return re2;
|
|
112
|
+
}
|
|
113
|
+
const re = f(s);
|
|
114
|
+
regexp.set(s, re);
|
|
115
|
+
return re;
|
|
116
|
+
};
|
|
92
117
|
export {
|
|
93
118
|
CDN,
|
|
94
119
|
compareVersion,
|
|
95
120
|
decodeHTML,
|
|
96
121
|
getLSP,
|
|
122
|
+
getObjRegex,
|
|
97
123
|
getObject,
|
|
124
|
+
getRegex,
|
|
98
125
|
loadScript,
|
|
99
126
|
normalizeTitle,
|
|
100
127
|
numToHex,
|
|
101
128
|
rawurldecode,
|
|
129
|
+
refreshStdout,
|
|
102
130
|
sanitizeInlineStyle,
|
|
103
131
|
setObject,
|
|
104
132
|
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.0",
|
|
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.2"
|
|
67
67
|
}
|
|
68
68
|
}
|