@zwa73/utils 1.0.274 → 1.0.276
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/QuickExport.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UtilFT } from "./UtilFileTools";
|
|
2
2
|
export declare const outcome: typeof import("@zwa73/js-utils").JsFunc.outcome, extractOutcome: typeof import("@zwa73/js-utils").JsFunc.extractOutcome, success: typeof import("@zwa73/js-utils").JsFunc.success, failed: typeof import("@zwa73/js-utils").JsFunc.failed, match: typeof import("@zwa73/js-utils").JsFunc.match, isSafeNumber: typeof import("@zwa73/js-utils").JsFunc.isSafeNumber, assertType: typeof import("@zwa73/js-utils").JsFunc.assertType, assertLiteral: typeof import("@zwa73/js-utils").JsFunc.assertLiteral, deepClone: typeof import("@zwa73/js-utils").JsFunc.deepClone, sleep: typeof import("@zwa73/js-utils").JsFunc.sleep, stringifyJToken: typeof import("@zwa73/js-utils").JsFunc.stringifyJToken, getTime: typeof import("@zwa73/js-utils").JsFunc.getTime, mapEntries: typeof import("@zwa73/js-utils").JsFunc.mapEntries, dedent: typeof import("@zwa73/js-utils").JsFunc.dedent, throwError: typeof import("@zwa73/js-utils").JsFunc.throwError, eitherize: typeof import("@zwa73/js-utils").JsFunc.eitherize, memoize: typeof import("@zwa73/js-utils").JsFunc.memoize, lazyFunction: typeof import("@zwa73/js-utils").JsFunc.lazyFunction, ivk: typeof import("@zwa73/js-utils").JsFunc.ivk, l2s: typeof import("@zwa73/js-utils").JsFunc.l2s, s2l: typeof import("@zwa73/js-utils").JsFunc.s2l, structEqual: typeof import("@zwa73/js-utils").JsFunc.structEqual, range: typeof import("@zwa73/js-utils").JsFunc.range, preset: typeof import("@zwa73/js-utils").JsFunc.preset, assignOption: typeof import("@zwa73/js-utils").JsFunc.assignOption;
|
|
3
3
|
export declare const stylizePath: typeof UtilFT.stylizePath, posixizePath: typeof UtilFT.posixizePath, win32izePath: typeof UtilFT.win32izePath, currosizePath: typeof UtilFT.currosizePath;
|
|
4
|
-
export declare const when: <S extends import("@zwa73/js-utils").Keyable, T, R>(stat: import("@zwa73/js-utils").Literal<S>, f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<S>>) => R) => (arg: T) => (false extends (symbol extends T ? S extends T & symbol ? false : true : string extends T ? S extends T & string ? false : true : number extends T ? S extends T & number ? false : true : true) ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends S ? Exclude<T, import("@zwa73/js-utils").Matchable<S>> | R : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<S, import("@zwa73/js-utils").MatchableFlag<T>> ? T : Exclude<T, import("@zwa73/js-utils").Matchable<S>> | R), map: typeof import("@zwa73/js-utils").JsFP.map, flow: typeof import("@zwa73/js-utils").JsFP.flow, pipe: typeof import("@zwa73/js-utils").JsFP.pipe, chain: <T, R>(f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Success>>) => R) => (arg: T) =>
|
|
4
|
+
export declare const when: <const S extends import("@zwa73/js-utils").Keyable, T, R>(stat: import("@zwa73/js-utils").Literal<S>, f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<S>>) => R) => (arg: T) => (false extends (symbol extends T ? S extends T & symbol ? false : true : string extends T ? S extends T & string ? false : true : number extends T ? S extends T & number ? false : true : true) ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends S ? Exclude<T, import("@zwa73/js-utils").Matchable<S>> | R : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<S, import("@zwa73/js-utils").MatchableFlag<T>> ? T : Exclude<T, import("@zwa73/js-utils").Matchable<S>> | R), map: typeof import("@zwa73/js-utils").JsFP.map, flow: typeof import("@zwa73/js-utils").JsFP.flow, pipe: typeof import("@zwa73/js-utils").JsFP.pipe, chain: <T, R>(f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Success>>) => R) => (arg: T) => false extends (symbol extends T ? typeof import("@zwa73/js-utils").Success extends infer T_1 ? T_1 extends typeof import("@zwa73/js-utils").Success ? T_1 extends T & symbol ? false : true : never : never : string extends T ? typeof import("@zwa73/js-utils").Success extends infer T_2 ? T_2 extends typeof import("@zwa73/js-utils").Success ? T_2 extends T & string ? false : true : never : never : number extends T ? typeof import("@zwa73/js-utils").Success extends infer T_3 ? T_3 extends typeof import("@zwa73/js-utils").Success ? T_3 extends T & number ? false : true : never : never : true) ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends typeof import("@zwa73/js-utils").Success ? R | Exclude<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Success>> : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<typeof import("@zwa73/js-utils").Success, import("@zwa73/js-utils").MatchableFlag<T>> ? T : R | Exclude<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Success>>, alt: <T, R>(f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Failed>>) => R) => (arg: T) => false extends (symbol extends T ? typeof import("@zwa73/js-utils").Failed extends infer T_1 ? T_1 extends typeof import("@zwa73/js-utils").Failed ? T_1 extends T & symbol ? false : true : never : never : string extends T ? typeof import("@zwa73/js-utils").Failed extends infer T_2 ? T_2 extends typeof import("@zwa73/js-utils").Failed ? T_2 extends T & string ? false : true : never : never : number extends T ? typeof import("@zwa73/js-utils").Failed extends infer T_3 ? T_3 extends typeof import("@zwa73/js-utils").Failed ? T_3 extends T & number ? false : true : never : never : true) ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends typeof import("@zwa73/js-utils").Failed ? R | Exclude<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Failed>> : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<typeof import("@zwa73/js-utils").Failed, import("@zwa73/js-utils").MatchableFlag<T>> ? T : R | Exclude<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Failed>>, tap: typeof import("@zwa73/js-utils").JsFP.tap, curry: typeof import("@zwa73/js-utils").JsFP.curry;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MPromise } from '@zwa73/js-utils';
|
|
1
2
|
import type { stringify } from 'yaml';
|
|
2
3
|
type ExtractBlockOpt = {
|
|
3
4
|
/**要提取的标题 必须为 "# 标题" 的格式 */
|
|
@@ -10,16 +11,25 @@ type FromArg = {
|
|
|
10
11
|
content?: string;
|
|
11
12
|
};
|
|
12
13
|
/**Markdown解析器 */
|
|
13
|
-
export declare class Markdown {
|
|
14
|
-
|
|
14
|
+
export declare class Markdown<D extends Record<string, any> = Record<string, any>> {
|
|
15
|
+
/**yaml数据 */
|
|
16
|
+
data?: D | undefined;
|
|
17
|
+
/**md文本内容 */
|
|
15
18
|
content?: string | undefined;
|
|
16
19
|
private constructor();
|
|
17
20
|
/**从内容文本构建Md */
|
|
18
|
-
static parse(ctx?: string): Promise<Markdown
|
|
21
|
+
static parse(ctx?: string): Promise<Markdown<Record<string, any>>>;
|
|
19
22
|
/**从文件构建Md */
|
|
20
|
-
static fromFile(filepath: string): Promise<Markdown
|
|
23
|
+
static fromFile(filepath: string): Promise<Markdown<Record<string, any>>>;
|
|
21
24
|
/**从数据构建 */
|
|
22
|
-
static from(arg?: FromArg): Markdown
|
|
25
|
+
static from(arg?: FromArg): Markdown<Record<string, any>>;
|
|
26
|
+
/**辅助构建文本 */
|
|
27
|
+
static buildContent(obj: Record<string, (() => MPromise<string | undefined>) | string | undefined>): Promise<string>;
|
|
28
|
+
/**辅助构建代码块
|
|
29
|
+
* @param content - 代码内容
|
|
30
|
+
* @param lang - 代码块语言类型
|
|
31
|
+
*/
|
|
32
|
+
static buildCodeBlock(content: string, lang?: string): Promise<string>;
|
|
23
33
|
/**输出md文本 */
|
|
24
34
|
stringify(opt: Exclude<Parameters<typeof stringify>[2], string | number>): Promise<string>;
|
|
25
35
|
/**根据标题提取块
|
|
@@ -24,7 +24,11 @@ const getYaml = async () => {
|
|
|
24
24
|
class Markdown {
|
|
25
25
|
data;
|
|
26
26
|
content;
|
|
27
|
-
constructor(
|
|
27
|
+
constructor(
|
|
28
|
+
/**yaml数据 */
|
|
29
|
+
data,
|
|
30
|
+
/**md文本内容 */
|
|
31
|
+
content) {
|
|
28
32
|
this.data = data;
|
|
29
33
|
this.content = content;
|
|
30
34
|
}
|
|
@@ -42,9 +46,34 @@ class Markdown {
|
|
|
42
46
|
static from(arg = {}) {
|
|
43
47
|
return new Markdown(arg.data, arg.content);
|
|
44
48
|
}
|
|
49
|
+
/**辅助构建文本 */
|
|
50
|
+
static async buildContent(obj) {
|
|
51
|
+
return Promise.all(Object.entries(obj).map(async ([k, v]) => {
|
|
52
|
+
const vtxt = typeof v == 'function' ? await v() : v;
|
|
53
|
+
if (vtxt != undefined && vtxt.length > 0)
|
|
54
|
+
return `${k}\n${vtxt}`;
|
|
55
|
+
return undefined;
|
|
56
|
+
})).then(p => p.filter(v => v != undefined).join('\n\n'));
|
|
57
|
+
}
|
|
58
|
+
/**辅助构建代码块
|
|
59
|
+
* @param content - 代码内容
|
|
60
|
+
* @param lang - 代码块语言类型
|
|
61
|
+
*/
|
|
62
|
+
static async buildCodeBlock(content, lang) {
|
|
63
|
+
return '```' + (lang ?? '') + content + '```';
|
|
64
|
+
}
|
|
45
65
|
/**输出md文本 */
|
|
46
66
|
async stringify(opt) {
|
|
47
|
-
const
|
|
67
|
+
const fxopt = Object.assign({
|
|
68
|
+
blockQuote: false,
|
|
69
|
+
doubleQuotedAsJSON: true,
|
|
70
|
+
singleQuote: true,
|
|
71
|
+
defaultStringType: "QUOTE_SINGLE",
|
|
72
|
+
defaultKeyType: "PLAIN",
|
|
73
|
+
lineWidth: 0,
|
|
74
|
+
minContentWidth: 0,
|
|
75
|
+
}, opt);
|
|
76
|
+
const yamlText = Object.values(this.data ?? {}).length > 0 ? `---\n${(await getYaml()).stringify(this.data, fxopt)}---\n` : '';
|
|
48
77
|
return `${yamlText}${this.content}`;
|
|
49
78
|
//return (await getMatter()).stringify(this.content,this.data);
|
|
50
79
|
}
|
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JsFunc } from "@zwa73/js-utils";
|
|
2
2
|
import type { LogLevel } from "./UtilInterfaces";
|
|
3
|
-
export type { PromiseRetries, PromiseRetryResult } from "@zwa73/js-utils";
|
|
4
3
|
declare const HashAlgorithmList: readonly ["RSA-MD5", "RSA-RIPEMD160", "RSA-SHA1", "RSA-SHA1-2", "RSA-SHA224", "RSA-SHA256", "RSA-SHA3-224", "RSA-SHA3-256", "RSA-SHA3-384", "RSA-SHA3-512", "RSA-SHA384", "RSA-SHA512", "RSA-SHA512/224", "RSA-SHA512/256", "RSA-SM3", "blake2b512", "blake2s256", "id-rsassa-pkcs1-v1_5-with-sha3-224", "id-rsassa-pkcs1-v1_5-with-sha3-256", "id-rsassa-pkcs1-v1_5-with-sha3-384", "id-rsassa-pkcs1-v1_5-with-sha3-512", "md5", "md5-sha1", "md5WithRSAEncryption", "ripemd", "ripemd160", "ripemd160WithRSA", "rmd160", "sha1", "sha1WithRSAEncryption", "sha224", "sha224WithRSAEncryption", "sha256", "sha256WithRSAEncryption", "sha3-224", "sha3-256", "sha3-384", "sha3-512", "sha384", "sha384WithRSAEncryption", "sha512", "sha512-224", "sha512-224WithRSAEncryption", "sha512-256", "sha512-256WithRSAEncryption", "sha512WithRSAEncryption", "shake128", "shake256", "sm3", "sm3WithRSAEncryption", "ssl3-md5", "ssl3-sha1"];
|
|
5
4
|
export type HashAlgorithm = typeof HashAlgorithmList[number];
|
|
6
5
|
/**执行选项 */
|
|
@@ -47,5 +46,6 @@ declare class _UtilFunc {
|
|
|
47
46
|
*/
|
|
48
47
|
static getPublicIpv4(): Promise<string | undefined>;
|
|
49
48
|
}
|
|
50
|
-
export declare const UtilFunc: import("@zwa73/modular-mixer").ComposedClass<typeof _UtilFunc, typeof JsFunc, "__jsUtils", "
|
|
49
|
+
export declare const UtilFunc: import("@zwa73/modular-mixer").ComposedClass<typeof _UtilFunc, typeof JsFunc, "__jsUtils", "prototype" | "preset" | "assignOption" | "genUUID" | "getTime" | "initField" | "initObject" | "afterward" | "sleep" | "getNeverResolvedPromise" | "retryPromise" | "timelimitPromise" | "mapEntries" | "eachField" | "stringifyJToken" | "sortJToken" | "assertType" | "assertLiteral" | "deepClone" | "isSafeNumber" | "dedent" | "throwError" | "getStack" | "getFuncLoc" | "cachePool" | "memoize" | "asyncize" | "lazyFunction" | "splitToChunk" | "mergeFromChunk" | "structEqual" | "concurrent" | "dynamicImport" | "createInjectable" | "createAsyncProxy" | "checkSharpSchema" | "unwarpReadonly" | "outcome" | "extractOutcome" | "success" | "failed" | "match" | "isStatus" | "eitherize" | "parseSrtTime" | "formatSrtTime" | "parseSrt" | "createSrt" | "ivk" | "range" | "s2l" | "l2s">;
|
|
51
50
|
export type UtilFunc = typeof UtilFunc;
|
|
51
|
+
export {};
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -96,19 +96,22 @@ class _UtilFunc {
|
|
|
96
96
|
let stderr = '';
|
|
97
97
|
child.stdout.on('data', (data) => {
|
|
98
98
|
stdout += data;
|
|
99
|
-
if (opt?.outlvl)
|
|
99
|
+
if (opt?.outlvl) {
|
|
100
|
+
const text = data.toString().replace(/\r?\n$/, '');
|
|
100
101
|
if (typeof opt.outlvl === "function")
|
|
101
|
-
opt.outlvl(
|
|
102
|
+
opt.outlvl(text);
|
|
102
103
|
else
|
|
103
|
-
UtilLogger_1.SLogger.log(opt?.outlvl,
|
|
104
|
+
UtilLogger_1.SLogger.log(opt?.outlvl, text);
|
|
105
|
+
}
|
|
104
106
|
});
|
|
105
107
|
child.stderr.on('data', (data) => {
|
|
106
108
|
stderr += data;
|
|
107
109
|
if (opt?.errlvl) {
|
|
110
|
+
const text = data.toString().replace(/\r?\n$/, '');
|
|
108
111
|
if (typeof opt.errlvl === "function")
|
|
109
|
-
opt.errlvl(
|
|
112
|
+
opt.errlvl(text);
|
|
110
113
|
else
|
|
111
|
-
UtilLogger_1.SLogger.log(opt?.errlvl,
|
|
114
|
+
UtilLogger_1.SLogger.log(opt?.errlvl, text);
|
|
112
115
|
}
|
|
113
116
|
});
|
|
114
117
|
child.on('error', reject);
|
package/dist/UtilHttp.js
CHANGED
|
@@ -11,8 +11,8 @@ const querystring_1 = __importDefault(require("querystring"));
|
|
|
11
11
|
const url_1 = require("url");
|
|
12
12
|
const js_utils_1 = require("@zwa73/js-utils");
|
|
13
13
|
const form_data_1 = __importDefault(require("form-data"));
|
|
14
|
-
const http_proxy_agent_1 =
|
|
15
|
-
const https_proxy_agent_1 =
|
|
14
|
+
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
15
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
16
16
|
const pathe_1 = __importDefault(require("pathe"));
|
|
17
17
|
const UtilFunctions_1 = require("./UtilFunctions");
|
|
18
18
|
const UtilLogger_1 = require("./UtilLogger");
|
|
@@ -104,8 +104,8 @@ class UtilHttp {
|
|
|
104
104
|
/**设置agent */
|
|
105
105
|
proxyAgent(url) {
|
|
106
106
|
this._data.agent = UtilFunctions_1.UtilFunc.match(this._data['protocol'], {
|
|
107
|
-
'http:': () =>
|
|
108
|
-
'https:': () =>
|
|
107
|
+
'http:': () => new http_proxy_agent_1.HttpProxyAgent(url),
|
|
108
|
+
'https:': () => new https_proxy_agent_1.HttpsProxyAgent(url),
|
|
109
109
|
});
|
|
110
110
|
return this;
|
|
111
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zwa73/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.276",
|
|
4
4
|
"description": "my utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"form-data": "^4.0.2",
|
|
22
22
|
"glob": "^10.4.1",
|
|
23
23
|
"html-entities": "^2.3.3",
|
|
24
|
-
"http-proxy-agent": "^
|
|
25
|
-
"https-proxy-agent": "^
|
|
24
|
+
"http-proxy-agent": "^7.0.2",
|
|
25
|
+
"https-proxy-agent": "^7.0.6",
|
|
26
26
|
"json5": "^2.2.3",
|
|
27
27
|
"pathe": "^1.1.2",
|
|
28
28
|
"querystring": "^0.2.1",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@deepkit/type": "^1.0.1-alpha.153",
|
|
54
54
|
"@types/jest": "^29.5.12",
|
|
55
|
-
"@types/node": "^20.
|
|
55
|
+
"@types/node": "^20.19.25",
|
|
56
56
|
"@zwa73/dev-utils": "*",
|
|
57
57
|
"handlebars": "^4.7.8",
|
|
58
58
|
"public-ip": "^6.0.2",
|