@zwa73/utils 1.0.194 → 1.0.195
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/UtilClass.d.ts +7 -4
- package/dist/UtilClass.js +4 -1
- package/dist/UtilFunctions.d.ts +2 -2
- package/dist/UtilInterfaces.d.ts +3 -1
- package/package.json +1 -1
- package/src/UtilClass.ts +9 -6
- package/src/UtilFunctions.ts +2 -2
- package/src/UtilInterfaces.ts +3 -1
package/dist/UtilClass.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Keyable, Literal } from "./UtilInterfaces";
|
|
1
|
+
import { Keyable, Literal, MPromise } from "./UtilInterfaces";
|
|
2
2
|
import Handlebars from 'handlebars';
|
|
3
3
|
/**函数管道器 */
|
|
4
4
|
export declare class Piper<Arg, Result = Arg> {
|
|
@@ -18,7 +18,7 @@ export declare class Piper<Arg, Result = Arg> {
|
|
|
18
18
|
/**直接调用 */
|
|
19
19
|
invoke(arg: Arg): Result;
|
|
20
20
|
}
|
|
21
|
-
type StreamOperation<T, U> = (item: T) =>
|
|
21
|
+
type StreamOperation<T, U> = (item: T) => MPromise<U>;
|
|
22
22
|
/**并行流 */
|
|
23
23
|
export declare class Stream<T> implements Iterable<T> {
|
|
24
24
|
/**并发数*/
|
|
@@ -27,8 +27,11 @@ export declare class Stream<T> implements Iterable<T> {
|
|
|
27
27
|
/**加工函数列表*/
|
|
28
28
|
private _operation;
|
|
29
29
|
private constructor();
|
|
30
|
-
/**从arraylike创建流
|
|
31
|
-
|
|
30
|
+
/**从arraylike创建流
|
|
31
|
+
* @param args - arraylike
|
|
32
|
+
* @param concurrent - 并发数 默认 1
|
|
33
|
+
*/
|
|
34
|
+
static from<T>(args: ArrayLike<T>, concurrent?: number): Stream<T>;
|
|
32
35
|
/**从数组创建流 */
|
|
33
36
|
static of<T>(...args: T[]): Stream<T>;
|
|
34
37
|
/**设置并发数 */
|
package/dist/UtilClass.js
CHANGED
|
@@ -49,7 +49,10 @@ class Stream {
|
|
|
49
49
|
this._list = new Array(...base);
|
|
50
50
|
this._concurrent = concurrent;
|
|
51
51
|
}
|
|
52
|
-
/**从arraylike创建流
|
|
52
|
+
/**从arraylike创建流
|
|
53
|
+
* @param args - arraylike
|
|
54
|
+
* @param concurrent - 并发数 默认 1
|
|
55
|
+
*/
|
|
53
56
|
static from(args, concurrent = 1) {
|
|
54
57
|
return new Stream(Array.from(args), concurrent);
|
|
55
58
|
}
|
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PRecord, AnyFunc, ExtractOutcome, IJData, JObject, JToken, Keyable, Literal, Matchable, MatchableFlag, Outcome, ReqVerifyFn, ProperSubsetCheck, UnionToIntersection, AnyRecord, AllExtends, SrtSegment } from "./UtilInterfaces";
|
|
1
|
+
import { PRecord, AnyFunc, ExtractOutcome, IJData, JObject, JToken, Keyable, Literal, Matchable, MatchableFlag, Outcome, ReqVerifyFn, ProperSubsetCheck, UnionToIntersection, AnyRecord, AllExtends, SrtSegment, MPromise } from "./UtilInterfaces";
|
|
2
2
|
import { LogLevel } from "./UtilLogger";
|
|
3
3
|
import { Failed, FailedLike, None, StatusSymbol, Success, SuccessLike, Timeout } from "./UtilSymbol";
|
|
4
4
|
declare const HashMethodList: readonly ["md5", "sha1", "sha256", "sha512", "sha3", "blake2", "blake3"];
|
|
@@ -119,7 +119,7 @@ export declare class UtilFunc {
|
|
|
119
119
|
* @param timeLimit - 毫秒限时
|
|
120
120
|
* @returns 超时则返回 处理函数委托 完成则返回结果
|
|
121
121
|
*/
|
|
122
|
-
static timelimitPromise<T>(func: () =>
|
|
122
|
+
static timelimitPromise<T>(func: () => MPromise<T>, timeLimit?: number): Promise<SuccessOut<T> | TimeoutOut<T>>;
|
|
123
123
|
/**对对象的每个属性应用映射函数,并返回一个新的对象。
|
|
124
124
|
* @template T - 对象的类型
|
|
125
125
|
* @param obj - 要处理的对象
|
package/dist/UtilInterfaces.d.ts
CHANGED
|
@@ -154,8 +154,10 @@ export type NeedInit = {
|
|
|
154
154
|
/**完成初始化的标记 */
|
|
155
155
|
inited: Promise<any>;
|
|
156
156
|
};
|
|
157
|
-
/**可选的record */
|
|
157
|
+
/**可选的record PartialRecord */
|
|
158
158
|
export type PRecord<K extends Keyable, V> = Partial<Record<K, V>>;
|
|
159
|
+
/** 可以是Promise MaybePromise*/
|
|
160
|
+
export type MPromise<T> = T | Promise<T>;
|
|
159
161
|
/**任何Record */
|
|
160
162
|
export type AnyRecord = Record<Keyable, any>;
|
|
161
163
|
/**注释元组
|
package/package.json
CHANGED
package/src/UtilClass.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { matchProc } from "./QuickExport";
|
|
2
|
-
import { Keyable, Literal } from "./UtilInterfaces";
|
|
2
|
+
import { Keyable, Literal, MPromise } from "./UtilInterfaces";
|
|
3
3
|
import Handlebars from 'handlebars';
|
|
4
4
|
import { SLogger } from "./UtilLogger";
|
|
5
5
|
|
|
@@ -38,7 +38,7 @@ export class Piper<Arg, Result = Arg> {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
type StreamOperation<T, U> = (item: T)=>
|
|
41
|
+
type StreamOperation<T, U> = (item: T)=>MPromise<U>;
|
|
42
42
|
/**并行流 */
|
|
43
43
|
export class Stream<T> implements Iterable<T>{
|
|
44
44
|
/**并发数*/
|
|
@@ -52,13 +52,16 @@ export class Stream<T> implements Iterable<T>{
|
|
|
52
52
|
else this._list = new Array(...base);
|
|
53
53
|
this._concurrent = concurrent;
|
|
54
54
|
}
|
|
55
|
-
/**从arraylike创建流
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
/**从arraylike创建流
|
|
56
|
+
* @param args - arraylike
|
|
57
|
+
* @param concurrent - 并发数 默认 1
|
|
58
|
+
*/
|
|
59
|
+
static from<T>(args:ArrayLike<T>,concurrent:number=1){
|
|
60
|
+
return new Stream(Array.from(args),concurrent);
|
|
58
61
|
}
|
|
59
62
|
/**从数组创建流 */
|
|
60
63
|
static of<T>(...args:T[]){
|
|
61
|
-
return new Stream
|
|
64
|
+
return new Stream(args);
|
|
62
65
|
}
|
|
63
66
|
/**设置并发数 */
|
|
64
67
|
concurrent(count: number): Stream<T> {
|
package/src/UtilFunctions.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as crypto from "crypto";
|
|
2
|
-
import { PRecord, AnyFunc, ExtractOutcome, IJData, JObject, JToken, Keyable, Literal, Matchable, MatchableFlag, Outcome, ReqStat, ReqVerifyFn, ProperSubsetCheck, UnionToIntersection, AnyRecord, AllExtends, SrtSegment } from "@/src/UtilInterfaces";
|
|
2
|
+
import { PRecord, AnyFunc, ExtractOutcome, IJData, JObject, JToken, Keyable, Literal, Matchable, MatchableFlag, Outcome, ReqStat, ReqVerifyFn, ProperSubsetCheck, UnionToIntersection, AnyRecord, AllExtends, SrtSegment, MPromise } from "@/src/UtilInterfaces";
|
|
3
3
|
import * as cp from "child_process";
|
|
4
4
|
import { LogLevel, SLogger } from "@/src/UtilLogger";
|
|
5
5
|
import { Completed, Failed, FailedLike, None, StatusSymbol, Success, SuccessLike, Terminated, Timeout } from "./UtilSymbol";
|
|
@@ -356,7 +356,7 @@ Promise<RepeatPromiseResult<T>>{
|
|
|
356
356
|
* @returns 超时则返回 处理函数委托 完成则返回结果
|
|
357
357
|
*/
|
|
358
358
|
static timelimitPromise<T>
|
|
359
|
-
(func:()=>
|
|
359
|
+
(func:()=>MPromise<T>,timeLimit?:number):Promise<SuccessOut<T>|TimeoutOut<T>>{
|
|
360
360
|
return new Promise<SuccessOut<T>|TimeoutOut<T>>((reslove)=>{
|
|
361
361
|
let clearTimer:(()=>void)| null = null;
|
|
362
362
|
const procer = (async ()=>await func())();
|
package/src/UtilInterfaces.ts
CHANGED
|
@@ -236,8 +236,10 @@ export type NeedInit = {
|
|
|
236
236
|
inited: Promise<any>;
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
-
/**可选的record */
|
|
239
|
+
/**可选的record PartialRecord */
|
|
240
240
|
export type PRecord<K extends Keyable,V> = Partial<Record<K,V>>;
|
|
241
|
+
/** 可以是Promise MaybePromise*/
|
|
242
|
+
export type MPromise<T> = T | Promise<T>;
|
|
241
243
|
/**任何Record */
|
|
242
244
|
export type AnyRecord = Record<Keyable,any>;
|
|
243
245
|
|