@idlebox/common 1.3.8 → 1.3.11
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/common-alpha.d.ts +1020 -0
- package/dist/common-beta.d.ts +1010 -0
- package/dist/common-public.d.ts +1008 -0
- package/dist/common.d.ts +1020 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/docs/common.api.json +21737 -0
- package/docs/common.api.md +1139 -0
- package/docs/tsdoc-metadata.json +11 -0
- package/lib/array/arrayDiff.cjs.map +1 -10
- package/lib/array/arraySame.cjs.map +1 -10
- package/lib/array/arrayUnique.cjs.map +1 -10
- package/lib/array/normalizeArray.cjs.map +1 -10
- package/lib/array/sortAlpha.cjs.map +1 -10
- package/lib/date/consts.cjs.map +1 -10
- package/lib/date/isInvalid.cjs.map +1 -10
- package/lib/date/sibling.cjs.map +1 -10
- package/lib/date/timeString.cjs +4 -4
- package/lib/date/timeString.cjs.map +1 -10
- package/lib/date/unix.cjs.map +1 -10
- package/lib/debugging/serializable.cjs +125 -0
- package/lib/debugging/serializable.cjs.map +1 -0
- package/lib/debugging/serializable.js +118 -0
- package/lib/debugging/serializable.js.map +1 -0
- package/lib/debugging/tryInspect.cjs +1 -1
- package/lib/debugging/tryInspect.cjs.map +1 -10
- package/lib/error/convertUnknown.cjs +2 -2
- package/lib/error/convertUnknown.cjs.map +1 -10
- package/lib/error/getFrame.cjs.map +1 -10
- package/lib/function/asyncCallbackList.cjs +4 -14
- package/lib/function/asyncCallbackList.cjs.map +1 -10
- package/lib/function/callbackList.cjs +5 -20
- package/lib/function/callbackList.cjs.map +1 -10
- package/lib/function/delayCallbackList.cjs +6 -24
- package/lib/function/delayCallbackList.cjs.map +1 -10
- package/lib/function/functionName.cjs.map +1 -10
- package/lib/index.generated.cjs +341 -0
- package/lib/index.generated.cjs.map +1 -0
- package/lib/index.generated.js +219 -0
- package/lib/index.generated.js.map +1 -0
- package/lib/lifecycle/dispose/bridges/rxjs.cjs.map +1 -10
- package/lib/lifecycle/dispose/disposableEvent.cjs.map +1 -10
- package/lib/lifecycle/dispose/disposedError.cjs +3 -3
- package/lib/lifecycle/dispose/disposedError.cjs.map +1 -10
- package/lib/lifecycle/dispose/lifecycle.async.cjs +12 -44
- package/lib/lifecycle/dispose/lifecycle.async.cjs.map +1 -10
- package/lib/lifecycle/dispose/lifecycle.cjs.map +1 -10
- package/lib/lifecycle/dispose/lifecycle.global.cjs +9 -9
- package/lib/lifecycle/dispose/lifecycle.global.cjs.map +1 -10
- package/lib/lifecycle/dispose/lifecycle.sync.cjs +12 -51
- package/lib/lifecycle/dispose/lifecycle.sync.cjs.map +1 -10
- package/lib/lifecycle/event/event.cjs +20 -7
- package/lib/lifecycle/event/event.cjs.map +1 -10
- package/lib/lifecycle/event/event.js +19 -1
- package/lib/lifecycle/event/event.js.map +1 -1
- package/lib/lifecycle/event/memorized.cjs +38 -0
- package/lib/lifecycle/event/memorized.cjs.map +1 -0
- package/lib/lifecycle/event/memorized.js +34 -0
- package/lib/lifecycle/event/memorized.js.map +1 -0
- package/lib/lifecycle/promise/cancel.cjs.map +1 -10
- package/lib/lifecycle/promise/cancellationToken/driver.browser.cjs +3 -18
- package/lib/lifecycle/promise/cancellationToken/driver.browser.cjs.map +1 -10
- package/lib/lifecycle/promise/cancellationToken/driver.common.cjs +5 -20
- package/lib/lifecycle/promise/cancellationToken/driver.common.cjs.map +1 -10
- package/lib/lifecycle/promise/cancellationToken/source.cjs +10 -20
- package/lib/lifecycle/promise/cancellationToken/source.cjs.map +1 -10
- package/lib/lifecycle/promise/deferredPromise.cjs +5 -20
- package/lib/lifecycle/promise/deferredPromise.cjs.map +1 -10
- package/lib/lifecycle/timeout/timeout.cjs +4 -4
- package/lib/lifecycle/timeout/timeout.cjs.map +1 -10
- package/lib/lifecycle/timeout/timeoutError.cjs +2 -2
- package/lib/lifecycle/timeout/timeoutError.cjs.map +1 -10
- package/lib/log/logger.cjs +9 -24
- package/lib/log/logger.cjs.map +1 -10
- package/lib/mapSet/customSet.cjs +2 -12
- package/lib/mapSet/customSet.cjs.map +1 -10
- package/lib/mapSet/extendMap.cjs.map +1 -10
- package/lib/misc/assertNotNull.cjs.map +1 -10
- package/lib/object/definePublicConstant.cjs.map +1 -10
- package/lib/object/initOnRead.cjs.map +1 -10
- package/lib/object/objectPath.cjs.map +1 -10
- package/lib/object/objectSame.cjs +4 -4
- package/lib/object/objectSame.cjs.map +1 -10
- package/lib/path/isAbsolute.cjs.map +1 -10
- package/lib/path/normalizePath.cjs.map +1 -10
- package/lib/path/pathArray.cjs +7 -11
- package/lib/path/pathArray.cjs.map +1 -10
- package/lib/platform/globalObject.cjs +5 -1
- package/lib/platform/globalObject.cjs.map +1 -10
- package/lib/platform/globalObject.js +3 -0
- package/lib/platform/globalObject.js.map +1 -1
- package/lib/platform/globalSingleton.cjs +5 -5
- package/lib/platform/globalSingleton.cjs.map +1 -10
- package/lib/platform/globalSymbol.cjs +2 -2
- package/lib/platform/globalSymbol.cjs.map +1 -10
- package/lib/platform/os.cjs.map +1 -10
- package/lib/promise/awaitIterator.cjs.map +1 -10
- package/lib/promise/finishAllPromise.cjs.map +1 -10
- package/lib/promise/promiseBool.cjs.map +1 -10
- package/lib/promise/promisePool.cjs +5 -12
- package/lib/promise/promisePool.cjs.map +1 -10
- package/lib/promise/timeoutPromisePool.cjs +6 -10
- package/lib/promise/timeoutPromisePool.cjs.map +1 -10
- package/lib/reflection/classes/hookClass.cjs.map +1 -10
- package/lib/reflection/classes/singleton.cjs +2 -2
- package/lib/reflection/classes/singleton.cjs.map +1 -10
- package/lib/reflection/methods/bind.cjs.map +1 -10
- package/lib/reflection/methods/initOnRead.cjs +2 -2
- package/lib/reflection/methods/initOnRead.cjs.map +1 -10
- package/lib/reflection/methods/memorize.cjs.map +1 -10
- package/lib/string/castCase.cjs.map +1 -10
- package/lib/string/concatType.generated.cjs.map +1 -10
- package/lib/string/escapeRegexp.cjs.map +1 -10
- package/lib/string/pad2.cjs.map +1 -10
- package/lib/string/sizeString.cjs.map +1 -10
- package/lib/typingHeler/deep.cjs +1 -0
- package/lib/typingHeler/deep.cjs.map +1 -10
- package/lib/typingHeler/deep.js +1 -0
- package/lib/typingHeler/deep.js.map +1 -1
- package/package.json +42 -42
- package/generate/main.ts +0 -56
- package/generate/package.json +0 -3
- package/generate/tsconfig.json +0 -9
- package/lib/_export_all_in_one_index.cjs +0 -176
- package/lib/_export_all_in_one_index.cjs.map +0 -10
- package/lib/_export_all_in_one_index.js +0 -61
- package/lib/_export_all_in_one_index.js.map +0 -1
|
@@ -0,0 +1,1020 @@
|
|
|
1
|
+
/// <reference types="@idlebox/itypes" />
|
|
2
|
+
|
|
3
|
+
export declare function addDisposableEventListener<T extends Function>(target: IEventHostObject<T> | IEventEmitterObject<T>, type: string, options: IEventListenerOptions, handler: T): IDisposable;
|
|
4
|
+
|
|
5
|
+
export declare function addDisposableEventListener<T extends Function>(target: IEventHostObject<T> | IEventEmitterObject<T>, type: string, handler: T): IDisposable;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compare two array, returns the difference from `before` to `after`
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function arrayDiff<T>(before: T[], after: T[]): {
|
|
12
|
+
add: T[];
|
|
13
|
+
del: T[];
|
|
14
|
+
same: T[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns a new array without duplicate values
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function arrayUnique<T>(arr: T[]): T[];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Removes duplicate values from an array
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function arrayUniqueReference(arr: any[]): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Assert function must have oneof displayName/name property
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertFunctionHasName(func: MaybeNamedFunction): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* assert value is not null or undefined or NaN
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare function assertNotNull<T>(val: T | null | undefined): T;
|
|
39
|
+
|
|
40
|
+
export declare function assertSerializable(value: any): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* like CallbackList, but async
|
|
44
|
+
*/
|
|
45
|
+
export declare class AsyncCallbackList<Argument extends unknown[]> {
|
|
46
|
+
protected list: MyAsyncCallback<Argument>[];
|
|
47
|
+
protected running: boolean;
|
|
48
|
+
constructor();
|
|
49
|
+
count(): number;
|
|
50
|
+
reset(): void;
|
|
51
|
+
/**
|
|
52
|
+
* @param name optional name of `item` (will assign displayName to `item`)
|
|
53
|
+
* @returns function list length
|
|
54
|
+
*/
|
|
55
|
+
add(item: MyAsyncCallback<Argument>, name?: string): number;
|
|
56
|
+
/**
|
|
57
|
+
* @returns if removed: return `item`; if did not exists: return null
|
|
58
|
+
*/
|
|
59
|
+
remove(item: MyAsyncCallback<Argument>): null | MyAsyncCallback<Argument>;
|
|
60
|
+
/**
|
|
61
|
+
* Stop run if one callback return `true`
|
|
62
|
+
* @returns {boolean} true if one callback return true
|
|
63
|
+
*/
|
|
64
|
+
run(...argument: Argument): Promise<boolean>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Async version of Disposable
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare class AsyncDisposable implements IAsyncDisposable, IDisposableBaseInternal {
|
|
72
|
+
private readonly _disposables;
|
|
73
|
+
protected readonly _onDisposeError: Emitter<Error>;
|
|
74
|
+
readonly onDisposeError: EventRegister<Error>;
|
|
75
|
+
protected readonly _onBeforeDispose: Emitter<void>;
|
|
76
|
+
readonly onBeforeDispose: EventRegister<void>;
|
|
77
|
+
private _disposed?;
|
|
78
|
+
get hasDisposed(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* @throws if already disposed
|
|
81
|
+
*/
|
|
82
|
+
assertNotDisposed(): void;
|
|
83
|
+
/**
|
|
84
|
+
* register a disposable object
|
|
85
|
+
*/
|
|
86
|
+
_register<T extends IAsyncDisposable>(d: T): T;
|
|
87
|
+
dispose(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Convert Iterator into Promise, resolve with the last value from Iterator
|
|
92
|
+
*/
|
|
93
|
+
export declare function awaitIterator<T>(generator: Iterator<T>): Promise<T>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Auto bind `this` to class method
|
|
97
|
+
*/
|
|
98
|
+
export declare const bindThis: MethodDecorator;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Manage a list of callback
|
|
102
|
+
*/
|
|
103
|
+
export declare class CallbackList<Argument extends unknown[]> {
|
|
104
|
+
protected list: MyCallback<Argument>[];
|
|
105
|
+
protected running: boolean;
|
|
106
|
+
protected stop: boolean;
|
|
107
|
+
constructor();
|
|
108
|
+
count(): number;
|
|
109
|
+
reset(): void;
|
|
110
|
+
/**
|
|
111
|
+
* @param name optional name of `item` (will assign displayName to `item`)
|
|
112
|
+
* @returns function list length
|
|
113
|
+
*/
|
|
114
|
+
add(item: MyCallback<Argument>, name?: string): number;
|
|
115
|
+
/**
|
|
116
|
+
* @returns if removed: return `item`; if did not exists: return null
|
|
117
|
+
*/
|
|
118
|
+
remove(item: MyCallback<Argument>): null | MyCallback<Argument>;
|
|
119
|
+
/**
|
|
120
|
+
* @returns {boolean} true if every callback called, false if stop in middle
|
|
121
|
+
*/
|
|
122
|
+
run(...argument: Argument): boolean;
|
|
123
|
+
stopRun(): void;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** @public */
|
|
127
|
+
export declare function camelCase(str: string): string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Error when cancel() is called
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export declare class CanceledError extends Error {
|
|
134
|
+
constructor();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @public */
|
|
138
|
+
export declare interface CancellationToken {
|
|
139
|
+
readonly isCancellationRequested: boolean;
|
|
140
|
+
onCancellationRequested(callback: EventHandler<void>): IDisposable;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** @public */
|
|
144
|
+
export declare class CancellationTokenSource extends DisposableOnce implements IDisposable {
|
|
145
|
+
private readonly driver;
|
|
146
|
+
readonly token: CancellationToken;
|
|
147
|
+
constructor();
|
|
148
|
+
cancel(): void;
|
|
149
|
+
_dispose(): void;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export declare enum ColorKind {
|
|
153
|
+
DISABLE = 0,
|
|
154
|
+
TERMINAL = 1,
|
|
155
|
+
WEB = 2,
|
|
156
|
+
DETECT = 3
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare function concatStringType<T0 extends string>(t0: T0): `${T0}`;
|
|
160
|
+
|
|
161
|
+
export declare function concatStringType<T0 extends string, T1 extends string>(t0: T0, t1: T1): `${T0}${T1}`;
|
|
162
|
+
|
|
163
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string>(t0: T0, t1: T1, t2: T2): `${T0}${T1}${T2}`;
|
|
164
|
+
|
|
165
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string>(t0: T0, t1: T1, t2: T2, t3: T3): `${T0}${T1}${T2}${T3}`;
|
|
166
|
+
|
|
167
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4): `${T0}${T1}${T2}${T3}${T4}`;
|
|
168
|
+
|
|
169
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): `${T0}${T1}${T2}${T3}${T4}${T5}`;
|
|
170
|
+
|
|
171
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}`;
|
|
172
|
+
|
|
173
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}`;
|
|
174
|
+
|
|
175
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}`;
|
|
176
|
+
|
|
177
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}`;
|
|
178
|
+
|
|
179
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}`;
|
|
180
|
+
|
|
181
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}`;
|
|
182
|
+
|
|
183
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}`;
|
|
184
|
+
|
|
185
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}`;
|
|
186
|
+
|
|
187
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13, t14: T14): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}`;
|
|
188
|
+
|
|
189
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13, t14: T14, t15: T15): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}`;
|
|
190
|
+
|
|
191
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13, t14: T14, t15: T15, t16: T16): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}`;
|
|
192
|
+
|
|
193
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string, T17 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13, t14: T14, t15: T15, t16: T16, t17: T17): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}`;
|
|
194
|
+
|
|
195
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string, T17 extends string, T18 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13, t14: T14, t15: T15, t16: T16, t17: T17, t18: T18): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}${T18}`;
|
|
196
|
+
|
|
197
|
+
export declare function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string, T17 extends string, T18 extends string, T19 extends string>(t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10, t11: T11, t12: T12, t13: T13, t14: T14, t15: T15, t16: T16, t17: T17, t18: T18, t19: T19): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}${T18}${T19}`;
|
|
198
|
+
|
|
199
|
+
export declare function convertCatchedError(e: unknown): Error;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get a symbol singleton, if not exists, create it
|
|
203
|
+
*
|
|
204
|
+
* this is very like Symbol.for, but not real global symbol
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export declare function createSymbol(category: string, name: string): symbol;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Like a Set, but use custom compare function insteadof ===
|
|
211
|
+
*/
|
|
212
|
+
export declare class CustomSet<Type = string> {
|
|
213
|
+
protected registry: Type[];
|
|
214
|
+
private finder;
|
|
215
|
+
constructor(finder?: Finder<Type>);
|
|
216
|
+
setFinder(finder: Finder<Type>): void;
|
|
217
|
+
has(item: Type): boolean;
|
|
218
|
+
add(item: Type): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* @returns all added values
|
|
221
|
+
*/
|
|
222
|
+
addAll(items: Type[]): Type[];
|
|
223
|
+
delete(item: Type): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* @returns all deleted values
|
|
226
|
+
*/
|
|
227
|
+
deleteAll(items: Type[]): Type[];
|
|
228
|
+
clear(): void;
|
|
229
|
+
get length(): number;
|
|
230
|
+
get size(): number;
|
|
231
|
+
[Symbol.iterator](): Iterator<Type>;
|
|
232
|
+
keys(): Iterator<Type>;
|
|
233
|
+
values(): Iterator<Type>;
|
|
234
|
+
toArray(): Type[];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export declare type DeepPartial<T> = {
|
|
238
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export declare type DeepReadonly<T> = {
|
|
242
|
+
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export declare type DeepWriteable<T> = {
|
|
246
|
+
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* a promise can resolve or reject later
|
|
251
|
+
* @public
|
|
252
|
+
*/
|
|
253
|
+
export declare class DeferredPromise<T, PT = any> {
|
|
254
|
+
readonly p: Promise<T> & IProgressHolder<T, PT>;
|
|
255
|
+
private _completeCallback;
|
|
256
|
+
private _errorCallback;
|
|
257
|
+
private _state;
|
|
258
|
+
private _progressList?;
|
|
259
|
+
constructor();
|
|
260
|
+
notify(progress: PT): this;
|
|
261
|
+
progress(fn: ProgressCallback<PT>): void;
|
|
262
|
+
get completed(): boolean;
|
|
263
|
+
get resolved(): boolean;
|
|
264
|
+
get rejected(): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* resolve the promise
|
|
267
|
+
*/
|
|
268
|
+
complete(value: T): void;
|
|
269
|
+
/**
|
|
270
|
+
* reject the promise
|
|
271
|
+
*/
|
|
272
|
+
error(err: any): void;
|
|
273
|
+
/**
|
|
274
|
+
* reject the promise with CancelError
|
|
275
|
+
*/
|
|
276
|
+
cancel(): void;
|
|
277
|
+
/**
|
|
278
|
+
* Convert promise into deferred
|
|
279
|
+
* returns a DeferredPromise, resolve when prev resolve, reject when prev reject
|
|
280
|
+
*/
|
|
281
|
+
static wrap(prev: Promise<any>): DeferredPromise<unknown, any>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export declare function definePublicConstant(object: any, propertyKey: string | symbol, value: any): void;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* remember arguments after run
|
|
288
|
+
* run all later added function with memorized argument
|
|
289
|
+
*/
|
|
290
|
+
export declare class DelayCallbackList<Argument extends unknown[]> {
|
|
291
|
+
private delayArgument?;
|
|
292
|
+
private delayComplete;
|
|
293
|
+
protected list?: MyDelayCallback<Argument>[];
|
|
294
|
+
count(): number;
|
|
295
|
+
add(item: MyDelayCallback<Argument>, name?: string): void;
|
|
296
|
+
run(argument: Argument): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Delete a symbol from window/global object
|
|
301
|
+
* @public
|
|
302
|
+
*/
|
|
303
|
+
export declare function deleteSymbol(category: string, name: string): void;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Standalone disposable class, can use as instance or base class.
|
|
307
|
+
*/
|
|
308
|
+
export declare class Disposable implements IDisposable, IDisposableBaseInternal {
|
|
309
|
+
private readonly _disposables;
|
|
310
|
+
protected readonly _onDisposeError: Emitter<Error>;
|
|
311
|
+
readonly onDisposeError: EventRegister<Error>;
|
|
312
|
+
protected readonly _onBeforeDispose: Emitter<void>;
|
|
313
|
+
readonly onBeforeDispose: EventRegister<void>;
|
|
314
|
+
private _disposed?;
|
|
315
|
+
get hasDisposed(): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* @throws if already disposed
|
|
318
|
+
*/
|
|
319
|
+
assertNotDisposed(): void;
|
|
320
|
+
_register<T extends IDisposable>(d: T): T;
|
|
321
|
+
dispose(): void;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export declare abstract class DisposableOnce implements IDisposable {
|
|
325
|
+
private _disposed?;
|
|
326
|
+
get hasDisposed(): boolean;
|
|
327
|
+
dispose(): void;
|
|
328
|
+
protected abstract _dispose(): void;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Error when call dispose() twice
|
|
333
|
+
*/
|
|
334
|
+
export declare class DisposedError extends Error {
|
|
335
|
+
constructor(object: any, previous: Error);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Dispose the global disposable store
|
|
340
|
+
* this function must be manually called by user, when registerGlobalLifecycle is used
|
|
341
|
+
*
|
|
342
|
+
* @throws when call twice
|
|
343
|
+
*/
|
|
344
|
+
export declare function disposeGlobal(): Promise<void>;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* 事件注册对象
|
|
348
|
+
* @public
|
|
349
|
+
*/
|
|
350
|
+
export declare class Emitter<T> implements IDisposable {
|
|
351
|
+
private readonly _callbacks;
|
|
352
|
+
constructor();
|
|
353
|
+
/**
|
|
354
|
+
* @returns 当前注册回调数量
|
|
355
|
+
*/
|
|
356
|
+
listenerCount(): number;
|
|
357
|
+
/**
|
|
358
|
+
* 触发本事件
|
|
359
|
+
* @param data 回调数据
|
|
360
|
+
*/
|
|
361
|
+
fire(data: T): void;
|
|
362
|
+
/**
|
|
363
|
+
* 与 `fire()`相同,但是忽略任何错误,并且即便出错也继续执行全部callback
|
|
364
|
+
*/
|
|
365
|
+
fireNoError(data: T): void;
|
|
366
|
+
/**
|
|
367
|
+
* 获取handle()方法的引用
|
|
368
|
+
*/
|
|
369
|
+
get register(): EventRegister<T>;
|
|
370
|
+
/**
|
|
371
|
+
* 注册本事件的新回调
|
|
372
|
+
* @param callback 回调函数
|
|
373
|
+
*/
|
|
374
|
+
handle(callback: EventHandler<T>): IDisposable;
|
|
375
|
+
dispose(): void;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Same as disposeGlobal, but do not throw by duplicate call
|
|
380
|
+
*/
|
|
381
|
+
export declare function ensureDisposeGlobal(): Promise<void>;
|
|
382
|
+
|
|
383
|
+
export declare function ensureGlobalObject<T>(symbol: string, constructor: () => T): T;
|
|
384
|
+
|
|
385
|
+
/** @public */
|
|
386
|
+
export declare function escapeRegExp(str: string): string;
|
|
387
|
+
|
|
388
|
+
export declare interface EventHandler<T> {
|
|
389
|
+
(data: T): void;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export declare interface EventRegister<T> {
|
|
393
|
+
(callback: EventHandler<T>): IDisposable;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* A map, will throw error when try to get not exists key
|
|
398
|
+
*/
|
|
399
|
+
export declare class ExtendMap<K, V> extends Map<K, V> {
|
|
400
|
+
/**
|
|
401
|
+
* Get value from map, if not exists, throw an error
|
|
402
|
+
*/
|
|
403
|
+
get(id: K): V;
|
|
404
|
+
/**
|
|
405
|
+
* Get value from map, if not exists, return def instead (not insert it into map)
|
|
406
|
+
*/
|
|
407
|
+
get(id: K, def: V): V;
|
|
408
|
+
/**
|
|
409
|
+
* Get a value, if not exists, call init() and set to map
|
|
410
|
+
*/
|
|
411
|
+
entry(id: K, init: (id: K) => V): V;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Find the index of given item */
|
|
415
|
+
export declare interface Finder<Type> {
|
|
416
|
+
(this: Type[], item: Type): number;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* @deprecated Use Promise.allSettled instead
|
|
421
|
+
*/
|
|
422
|
+
export declare function finishAllPromise<T>(ps: Promise<T>[]): Promise<PromiseResultArray<T>>;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Takes ms
|
|
426
|
+
*/
|
|
427
|
+
export declare function fromTimeStamp(timestamp: number): Date;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Get displayName/name of a function
|
|
431
|
+
*/
|
|
432
|
+
export declare function functionName(func: Function): string;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Get nth line of Error.stack
|
|
436
|
+
* @returns {string} if frame greater than max, return ''
|
|
437
|
+
*/
|
|
438
|
+
export declare function getErrorFrame(e: Error, frame: number): string;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Returns ms
|
|
442
|
+
*/
|
|
443
|
+
export declare function getTimeStamp(date: Date): number;
|
|
444
|
+
|
|
445
|
+
export declare function getTypeOf(value: any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "function" | "null" | "Promise" | "Error" | "DOM" | "EventTarget" | "unknown";
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* globalThis when supported.
|
|
449
|
+
* if not, window in browser, global in nodejs
|
|
450
|
+
* @public
|
|
451
|
+
*/
|
|
452
|
+
export declare const globalObject: any;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Same with globalSingletonStrong, but save instance in a WeakMap, so it maybe delete by gc if no reference
|
|
456
|
+
* @public
|
|
457
|
+
*/
|
|
458
|
+
export declare function globalSingleton<T>(symbol: symbol | string, constructor: () => T): T;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Same with globalSingletonStrong, but save instance in a WeakMap, so it maybe delete by gc if no reference
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
export declare function globalSingleton<T>(symbol: symbol | string): T | undefined;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Delete a key from window/global space
|
|
468
|
+
* use with care
|
|
469
|
+
* @public
|
|
470
|
+
*/
|
|
471
|
+
export declare function globalSingletonDelete(symbol: symbol | string): void;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Get an singleton instance from window/global space
|
|
475
|
+
* if symbol did not exists, create it and assign to window/global
|
|
476
|
+
* @public
|
|
477
|
+
*/
|
|
478
|
+
export declare function globalSingletonStrong<T>(symbol: symbol | string, constructor: () => T): T;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Get an singleton instance from window/global space
|
|
482
|
+
* @public
|
|
483
|
+
*/
|
|
484
|
+
export declare function globalSingletonStrong<T>(symbol: symbol | string): T | undefined;
|
|
485
|
+
|
|
486
|
+
export declare function hookClass<TC extends IConstructorOf<T>, T>(target: TC): IHooks<T, TC>;
|
|
487
|
+
|
|
488
|
+
export declare const hookClassSymbol: unique symbol;
|
|
489
|
+
|
|
490
|
+
export declare namespace humanDate {
|
|
491
|
+
/**
|
|
492
|
+
* Format: HH:mm:ss
|
|
493
|
+
*/
|
|
494
|
+
export function time(date: Date | string | number): string;
|
|
495
|
+
/**
|
|
496
|
+
* Format: YYYY-MM-dd
|
|
497
|
+
*
|
|
498
|
+
* separator can change
|
|
499
|
+
*/
|
|
500
|
+
export function date(date: Date | string | number, sp?: string): string;
|
|
501
|
+
/**
|
|
502
|
+
* Format: YYYY-MM-dd HH:mm:ss
|
|
503
|
+
*/
|
|
504
|
+
export function datetime(date: Date | string | number): string;
|
|
505
|
+
export interface ITimeFormatter {
|
|
506
|
+
(s: number): string;
|
|
507
|
+
}
|
|
508
|
+
export interface IFormatters {
|
|
509
|
+
s: ITimeFormatter;
|
|
510
|
+
m: ITimeFormatter;
|
|
511
|
+
h: ITimeFormatter;
|
|
512
|
+
d: ITimeFormatter;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* set format for time delta
|
|
516
|
+
*/
|
|
517
|
+
export function setLocaleFormatter(formatter: Partial<IFormatters>): void;
|
|
518
|
+
/**
|
|
519
|
+
* format time delta (in ms) to string, like: '1d'
|
|
520
|
+
* when ms<=0, returns '0s'
|
|
521
|
+
*
|
|
522
|
+
* format can set by `setLocaleFormatter`
|
|
523
|
+
* day is the largest unit
|
|
524
|
+
*/
|
|
525
|
+
export function deltaTiny(ms: number): string;
|
|
526
|
+
/**
|
|
527
|
+
* format time delta (in ms) to string, like: '1d10m42s'
|
|
528
|
+
* when ms<=0, returns '0s'
|
|
529
|
+
*
|
|
530
|
+
* format can set by `setLocaleFormatter`
|
|
531
|
+
* day is the largest unit
|
|
532
|
+
*/
|
|
533
|
+
export function delta(ms: number): string;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Convert bytes to largest unit, with binary prefix unit (1024), eg: 211.293GiB
|
|
538
|
+
* @public
|
|
539
|
+
*/
|
|
540
|
+
export declare function humanSize(bytes: number, fixed?: number): string;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Convert bytes to largest unit, with SI prefix unit (1000), eg: 211.293GB
|
|
544
|
+
* @public
|
|
545
|
+
*/
|
|
546
|
+
export declare function humanSizeSI(bytes: number, fixed?: number): string;
|
|
547
|
+
|
|
548
|
+
/** @deprecated */
|
|
549
|
+
export declare function humanSpeed(bps: number): string;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* @public
|
|
553
|
+
*/
|
|
554
|
+
export declare interface IArrayUpdate<T> {
|
|
555
|
+
add: T[];
|
|
556
|
+
del: T[];
|
|
557
|
+
same: T[];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** @public */
|
|
561
|
+
export declare interface IAsyncDisposable {
|
|
562
|
+
dispose(): void | Promise<void>;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
declare interface IConstructorOf<T> extends Object {
|
|
566
|
+
new (...args: any[]): T;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/** @public */
|
|
570
|
+
export declare interface IDisposable {
|
|
571
|
+
dispose(): void;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* @private
|
|
576
|
+
*/
|
|
577
|
+
export declare interface IDisposableBaseInternal {
|
|
578
|
+
onDisposeError: EventRegister<Error>;
|
|
579
|
+
onBeforeDispose: EventRegister<void>;
|
|
580
|
+
readonly hasDisposed: boolean;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export declare interface IEventEmitterObject<T extends Function> {
|
|
584
|
+
addListener(type: string, handler: T): any;
|
|
585
|
+
removeListener(type: string, handler: T): any;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export declare interface IEventHostObject<T extends Function> {
|
|
589
|
+
addEventListener(type: string, handler: T, options?: IEventListenerOptions): any;
|
|
590
|
+
removeEventListener(type: string, handler: T, options?: IEventListenerOptions): any;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export declare interface IEventListenerOptions {
|
|
594
|
+
capture?: boolean;
|
|
595
|
+
once?: boolean;
|
|
596
|
+
passive?: boolean;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
declare interface IHooks<T, TC> {
|
|
600
|
+
afterConstruct?: ((obj: T) => void)[];
|
|
601
|
+
beforeConstruct?: ((obj: TC) => T | void)[];
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Decorater version of `initOnRead`
|
|
606
|
+
* @see initOnRead
|
|
607
|
+
*/
|
|
608
|
+
export declare function init<O, T extends keyof O>(init: InitFunc<O, O[T]>): PropertyDecorator;
|
|
609
|
+
|
|
610
|
+
/** @public */
|
|
611
|
+
export declare interface InitFunc<O, T> {
|
|
612
|
+
(this: O): T;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Define property on target, call init it when first use, them memorize
|
|
617
|
+
* @public
|
|
618
|
+
*/
|
|
619
|
+
export declare function initOnRead<O, T extends keyof O>(target: any, propertyKey: T, init: InitFunc<O, O[T]>): void;
|
|
620
|
+
|
|
621
|
+
export declare interface IProgressHolder<T, PT> {
|
|
622
|
+
progress(fn: ProgressCallback<PT>): Promise<T> & IProgressHolder<T, PT>;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* return true if a path is absolute:
|
|
627
|
+
* - /xxxx
|
|
628
|
+
* - \xxxx
|
|
629
|
+
* - c:/
|
|
630
|
+
* - c:\
|
|
631
|
+
* - http://
|
|
632
|
+
*/
|
|
633
|
+
export declare function isAbsolute(path: string): boolean;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* is the two array EXACTLY same
|
|
637
|
+
* @public
|
|
638
|
+
*/
|
|
639
|
+
export declare function isArraySame<T>(a1: T[], a2: T[]): boolean;
|
|
640
|
+
|
|
641
|
+
/** @public */
|
|
642
|
+
export declare function isCanceledError(error: any): boolean;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Check if a date is NaN
|
|
646
|
+
*/
|
|
647
|
+
export declare function isDateInvalid(date: Date): boolean;
|
|
648
|
+
|
|
649
|
+
export declare function isDisposedError(error: any): boolean;
|
|
650
|
+
|
|
651
|
+
export declare const isElectron: boolean;
|
|
652
|
+
|
|
653
|
+
export declare const isElectronMain: boolean;
|
|
654
|
+
|
|
655
|
+
export declare const isElectronRenderer: boolean;
|
|
656
|
+
|
|
657
|
+
export declare const isLinux: boolean;
|
|
658
|
+
|
|
659
|
+
export declare const isMacintosh: boolean;
|
|
660
|
+
|
|
661
|
+
export declare const isNative: boolean;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Should ensure a and b is none-null before call this
|
|
665
|
+
* @returns true when a and b has EXACTLY same keys and values
|
|
666
|
+
*/
|
|
667
|
+
export declare function isObjectSame(a: any, b: any): boolean;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Should ensure a and b is none-null before call this
|
|
671
|
+
* @returns true when a and b has EXACTLY same keys and values, recursive compare all object values
|
|
672
|
+
*/
|
|
673
|
+
export declare function isObjectSameRecursive(a: any, b: any): boolean;
|
|
674
|
+
|
|
675
|
+
export declare function isScalar(value: any): value is bigint | number | boolean | string | symbol | undefined | null | Date;
|
|
676
|
+
|
|
677
|
+
export declare function isSerializable(value: any): SerializableKind;
|
|
678
|
+
|
|
679
|
+
/** @public */
|
|
680
|
+
export declare function isTimeoutError(error: Error): error is TimeoutError;
|
|
681
|
+
|
|
682
|
+
export declare const isWeb: boolean;
|
|
683
|
+
|
|
684
|
+
export declare const isWindows: boolean;
|
|
685
|
+
|
|
686
|
+
export declare interface IUniqueIdFactory<T> {
|
|
687
|
+
(item: T): string;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* lowercase first char
|
|
692
|
+
* @public
|
|
693
|
+
*/
|
|
694
|
+
export declare function lcfirst<T extends string>(str: T): Uncapitalize<T>;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Note: sub-class should singleton
|
|
698
|
+
* @alpha
|
|
699
|
+
*/
|
|
700
|
+
export declare abstract class LifecycleObject extends AsyncDisposable {
|
|
701
|
+
/** sub-class should shutdown program in this method */
|
|
702
|
+
protected abstract done(): void;
|
|
703
|
+
dispose(): Promise<void>;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** @public */
|
|
707
|
+
export declare function linux_case(str: string): string;
|
|
708
|
+
|
|
709
|
+
/** @public */
|
|
710
|
+
export declare function linux_case_hyphen(str: string): string;
|
|
711
|
+
|
|
712
|
+
export declare interface MapLike<V> {
|
|
713
|
+
[id: string]: V;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export declare interface MaybeNamedFunction extends Function {
|
|
717
|
+
displayName?: string;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Decorate class method/getter
|
|
722
|
+
*
|
|
723
|
+
* remember first return value of method/getter, directlly return memorized value when call it again
|
|
724
|
+
*/
|
|
725
|
+
export declare const memo: MethodDecorator;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* 会记住上次fire的内容,并在每个新的handler注册时立即调用一次的Emitter
|
|
729
|
+
* 显然,这会对fire的内容保留一个引用,可以调用forget()取消
|
|
730
|
+
* @public
|
|
731
|
+
*/
|
|
732
|
+
export declare class MemorizedEmitter<T> extends Emitter<T> {
|
|
733
|
+
private _memo?;
|
|
734
|
+
private _is_memo;
|
|
735
|
+
fire(data: T): void;
|
|
736
|
+
fireNoError(data: T): void;
|
|
737
|
+
handle(callback: EventHandler<T>): IDisposable;
|
|
738
|
+
forget(): void;
|
|
739
|
+
dispose(): void;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export declare const memorizeValueSymbol: unique symbol;
|
|
743
|
+
|
|
744
|
+
export declare interface MyAsyncCallback<Argument extends unknown[]> {
|
|
745
|
+
displayName?: string;
|
|
746
|
+
(...param: Argument): Promise<void | undefined | boolean> | void | undefined | boolean;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
export declare interface MyCallback<Argument extends unknown[]> {
|
|
750
|
+
displayName?: string;
|
|
751
|
+
(...param: Argument): any;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
export declare interface MyDelayCallback<Argument extends unknown[]> {
|
|
755
|
+
displayName?: string;
|
|
756
|
+
(...param: Argument): void;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Function with displayName
|
|
761
|
+
*/
|
|
762
|
+
export declare interface NamedFunction extends Function {
|
|
763
|
+
displayName: string;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Set displayName of a function
|
|
768
|
+
*/
|
|
769
|
+
export declare function nameFunction<T extends Function>(name: string, func: T): T & NamedFunction;
|
|
770
|
+
|
|
771
|
+
export declare function nextDay(d: Date, n?: number): Date;
|
|
772
|
+
|
|
773
|
+
export declare function nextHour(d: Date, n?: number): Date;
|
|
774
|
+
|
|
775
|
+
export declare function nextMinute(d: Date, n?: number): Date;
|
|
776
|
+
|
|
777
|
+
export declare function nextMonth(d: Date, n?: number): Date;
|
|
778
|
+
|
|
779
|
+
export declare function nextSecond(d: Date, n?: number): Date;
|
|
780
|
+
|
|
781
|
+
export declare function nextWeek(d: Date, n?: number): Date;
|
|
782
|
+
|
|
783
|
+
export declare function nextYear(d: Date, n?: number): Date;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* ensure a value is an array
|
|
787
|
+
* @public
|
|
788
|
+
*/
|
|
789
|
+
export declare function normalizeArray<T>(input: T | T[]): T[];
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* replace // to /
|
|
793
|
+
* replace \ to /
|
|
794
|
+
* remove ending /
|
|
795
|
+
*/
|
|
796
|
+
export declare function normalizePath(p: string): string;
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Get deep child property of an object
|
|
800
|
+
* @param path object path seprate by "."
|
|
801
|
+
*/
|
|
802
|
+
export declare function objectPath(obj: object, path: string): any;
|
|
803
|
+
|
|
804
|
+
export declare const oneDay = 86400000;
|
|
805
|
+
|
|
806
|
+
export declare const oneHour = 1440000;
|
|
807
|
+
|
|
808
|
+
export declare const oneMinute = 60000;
|
|
809
|
+
|
|
810
|
+
export declare const oneSecond = 1000;
|
|
811
|
+
|
|
812
|
+
export declare const oneWeek = 604800000;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Pad number to two digits string, used in time format
|
|
816
|
+
* @public
|
|
817
|
+
*/
|
|
818
|
+
export declare function pad2(s: number): string;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Work on "PATH"-like values
|
|
822
|
+
*/
|
|
823
|
+
export declare class PathArray extends Set<string> {
|
|
824
|
+
private readonly sep;
|
|
825
|
+
constructor(init: string, sep: ':' | ';');
|
|
826
|
+
add(paths: string): this;
|
|
827
|
+
delete(paths: string): boolean;
|
|
828
|
+
has(path: string): boolean;
|
|
829
|
+
toString(): string;
|
|
830
|
+
/**
|
|
831
|
+
* @returns an array with `part` append to every element
|
|
832
|
+
*/
|
|
833
|
+
join(part: string): string[];
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
export declare type ProgressCallback<T = any> = (value: T) => void;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* resolve with true when `p` resolve
|
|
840
|
+
* resolve with false when `p` reject (and drop error)
|
|
841
|
+
*/
|
|
842
|
+
export declare function promiseBool(p: Promise<any>): Promise<boolean>;
|
|
843
|
+
|
|
844
|
+
export declare class PromisePool {
|
|
845
|
+
protected readonly promiseList: Record<string, DeferredPromise<any>>;
|
|
846
|
+
size(): number;
|
|
847
|
+
create(id: string): Promise<any> & IProgressHolder<any, any>;
|
|
848
|
+
has(id: string): boolean;
|
|
849
|
+
done(id: string, data: any): void;
|
|
850
|
+
error(id: string, e: Error): void;
|
|
851
|
+
dispose(): void;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/** @deprecated */
|
|
855
|
+
export declare interface PromiseResultArray<T> {
|
|
856
|
+
count: number;
|
|
857
|
+
fulfilledResult: T[];
|
|
858
|
+
fulfilled: number[];
|
|
859
|
+
rejectedResult: Error[];
|
|
860
|
+
rejected: number[];
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
export declare function RegexpFinder(this: RegExp[], item: RegExp): number;
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Add object into global disposable store, it will be dispose when call to `disposeGlobal`
|
|
867
|
+
*/
|
|
868
|
+
export declare function registerGlobalLifecycle(object: IDisposable): void;
|
|
869
|
+
|
|
870
|
+
export declare enum SerializableKind {
|
|
871
|
+
Invalid = 0,
|
|
872
|
+
Primitive = 1,
|
|
873
|
+
Manual = 2,
|
|
874
|
+
Other = 3
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export declare function singleton(type?: SingletonType): ClassDecorator;
|
|
878
|
+
|
|
879
|
+
export declare const singletonSymbol: unique symbol;
|
|
880
|
+
|
|
881
|
+
export declare enum SingletonType {
|
|
882
|
+
Throw = 0,
|
|
883
|
+
Return = 1
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* @returns promise resolve after specific time
|
|
888
|
+
*/
|
|
889
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Sort string array alphabet order
|
|
893
|
+
*
|
|
894
|
+
* to be used in <arr>.sort()
|
|
895
|
+
* @public
|
|
896
|
+
*/
|
|
897
|
+
export declare function sortByString(a: string, b: string): number;
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* assert value is not null or undefined or NaN
|
|
901
|
+
* @throws Value is null or undefined
|
|
902
|
+
* @public
|
|
903
|
+
*/
|
|
904
|
+
export declare function throwNull<T>(val: T): NonNullable<T>;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @returns promise reject with TimeoutError after specific time
|
|
908
|
+
*/
|
|
909
|
+
export declare function timeout(ms: number, error?: string): Promise<never>;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Error when timeout() done
|
|
913
|
+
* @public
|
|
914
|
+
*/
|
|
915
|
+
export declare class TimeoutError extends Error {
|
|
916
|
+
constructor(time: number, what?: string);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
export declare function timeoutPromise<T>(ms: number, p: Promise<T>): Promise<T>;
|
|
920
|
+
|
|
921
|
+
export declare function timeoutPromise<T>(ms: number, message: string, p: Promise<T>): Promise<T>;
|
|
922
|
+
|
|
923
|
+
export declare function timeoutPromise<T, PT = any>(ms: number, p: DeferredPromise<T, PT>): DeferredPromise<T, PT>;
|
|
924
|
+
|
|
925
|
+
export declare function timeoutPromise<T, PT = any>(ms: number, message: string, p: DeferredPromise<T, PT>): DeferredPromise<T, PT>;
|
|
926
|
+
|
|
927
|
+
export declare class TimeoutPromisePool extends PromisePool {
|
|
928
|
+
private readonly defaultTimeoutMs;
|
|
929
|
+
constructor(defaultTimeoutMs?: number);
|
|
930
|
+
create(id: string, timeoutMs?: number, timeoutMsg?: string): Promise<any> & IProgressHolder<any, any>;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Convert "dispose function" to disposable object
|
|
935
|
+
* @public
|
|
936
|
+
*/
|
|
937
|
+
export declare function toDisposable(fn: () => void): IDisposable;
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* try to call `inspect` method of an object, if not exists, call `toString`.
|
|
941
|
+
* @returns {string}
|
|
942
|
+
*/
|
|
943
|
+
export declare function tryInspect(object: any): any;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Uppercase first char
|
|
947
|
+
* @public
|
|
948
|
+
*/
|
|
949
|
+
export declare function ucfirst<T extends string>(str: T): Capitalize<T>;
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Returns a function to be used in <arr>.filter()
|
|
953
|
+
*
|
|
954
|
+
* the returned function can use multiple times, it will remember all values inter multiple arrays
|
|
955
|
+
*
|
|
956
|
+
* @param {IUniqueIdFactory} idFactory function takes an array element, return it's id to be compare with each other
|
|
957
|
+
* @public
|
|
958
|
+
*/
|
|
959
|
+
export declare function uniqueFilter<T>(idFactory?: IUniqueIdFactory<T>): (item: T) => boolean;
|
|
960
|
+
|
|
961
|
+
declare interface Unsubscribable {
|
|
962
|
+
unsubscribe(): void;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
export declare function unsubscribableToDisposable(subscription: Unsubscribable): {
|
|
966
|
+
dispose: () => void;
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
export declare const userAgent: string;
|
|
970
|
+
|
|
971
|
+
export declare type ValueCallback<T = any> = (value: T | Promise<T>) => void;
|
|
972
|
+
|
|
973
|
+
export declare abstract class WrappedConsole {
|
|
974
|
+
info: Console['info'];
|
|
975
|
+
log: Console['log'];
|
|
976
|
+
success: Console['log'];
|
|
977
|
+
debug: Console['debug'];
|
|
978
|
+
error: Console['error'];
|
|
979
|
+
trace: Console['trace'];
|
|
980
|
+
warn: Console['warn'];
|
|
981
|
+
assert: Console['assert'];
|
|
982
|
+
time: Console['time'];
|
|
983
|
+
timeEnd: Console['timeEnd'];
|
|
984
|
+
timeLog: Console['timeLog'];
|
|
985
|
+
count: Console['count'];
|
|
986
|
+
countReset: Console['countReset'];
|
|
987
|
+
group: Console['group'];
|
|
988
|
+
groupCollapsed: Console['groupCollapsed'];
|
|
989
|
+
groupEnd: Console['groupEnd'];
|
|
990
|
+
table: Console['table'];
|
|
991
|
+
dir: Console['dir'];
|
|
992
|
+
clear: Console['clear'];
|
|
993
|
+
protected readonly title: string;
|
|
994
|
+
protected readonly parent: Console;
|
|
995
|
+
protected readonly bind: boolean;
|
|
996
|
+
constructor(title: string, { parent, bind }?: WrappedConsoleOptions);
|
|
997
|
+
protected wrap<T extends keyof Omit<Console & {
|
|
998
|
+
Console: any;
|
|
999
|
+
}, 'Console'>>(original: T): Function;
|
|
1000
|
+
private wrapSimple;
|
|
1001
|
+
private wrapExtra;
|
|
1002
|
+
protected createPrefix(message: string): string;
|
|
1003
|
+
private wrapMessageAt;
|
|
1004
|
+
private convertObjectArg;
|
|
1005
|
+
protected abstract processColorLabel(normalizedArguments: any[], messageLoc: number, level: string, prefix: string): void;
|
|
1006
|
+
protected uncolor(args: any[], pos: number, prefix: string, postfix: string): void;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
export declare interface WrappedConsoleOptions {
|
|
1010
|
+
parent?: Console;
|
|
1011
|
+
bind?: boolean;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
export declare type Writeable<T> = {
|
|
1015
|
+
-readonly [P in keyof T]: T[P];
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
export declare function x(): number;
|
|
1019
|
+
|
|
1020
|
+
export { }
|