@idlebox/common 1.3.14 → 1.3.16

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