@idlebox/common 1.3.15 → 1.3.17
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 → lib}/common-alpha.d.ts +10 -0
- package/{dist → lib}/common-beta.d.ts +10 -0
- package/{dist → lib}/common-public.d.ts +10 -0
- package/{dist → lib}/common.d.ts +10 -0
- package/lib/function/callbackList.cjs +4 -0
- package/lib/function/callbackList.cjs.map +1 -1
- package/lib/function/callbackList.js +4 -0
- package/lib/function/callbackList.js.map +1 -1
- package/lib/string/concatType.generated.cjs +8 -0
- package/lib/string/concatType.generated.cjs.map +1 -1
- package/lib/string/concatType.generated.js +8 -0
- package/lib/string/concatType.generated.js.map +1 -1
- package/{dist → lib}/tsdoc-metadata.json +1 -1
- package/package.json +13 -12
- package/src/array/arrayDiff.ts +31 -0
- package/src/array/arraySame.ts +15 -0
- package/src/array/arrayUnique.ts +50 -0
- package/src/array/normalizeArray.ts +13 -0
- package/src/array/sortAlpha.ts +15 -0
- package/src/date/consts.ts +5 -0
- package/src/date/isInvalid.ts +6 -0
- package/src/date/sibling.ts +28 -0
- package/src/date/timeString.ts +150 -0
- package/src/date/unix.ts +13 -0
- package/src/debugging/serializable.ts +146 -0
- package/src/debugging/tryInspect.ts +37 -0
- package/src/error/convertUnknown.ts +10 -0
- package/src/error/getFrame.ts +13 -0
- package/src/function/asyncCallbackList.ts +75 -0
- package/src/function/callbackList.ts +88 -0
- package/src/function/delayCallbackList.ts +45 -0
- package/src/function/functionName.ts +39 -0
- package/src/index.generated.ts +289 -0
- package/src/lifecycle/dispose/bridges/rxjs.ts +6 -0
- package/src/lifecycle/dispose/disposableEvent.ts +117 -0
- package/src/lifecycle/dispose/disposedError.ts +16 -0
- package/src/lifecycle/dispose/lifecycle.async.ts +61 -0
- package/src/lifecycle/dispose/lifecycle.global.ts +61 -0
- package/src/lifecycle/dispose/lifecycle.sync.ts +79 -0
- package/src/lifecycle/dispose/lifecycle.ts +28 -0
- package/src/lifecycle/event/event.ts +81 -0
- package/src/lifecycle/event/memorized.ts +39 -0
- package/src/lifecycle/promise/cancel.ts +16 -0
- package/src/lifecycle/promise/cancellationToken/driver.browser.ts +55 -0
- package/src/lifecycle/promise/cancellationToken/driver.common.ts +43 -0
- package/src/lifecycle/promise/cancellationToken/source.ts +48 -0
- package/src/lifecycle/promise/deferredPromise.ts +104 -0
- package/src/lifecycle/timeout/timeout.ts +48 -0
- package/src/lifecycle/timeout/timeoutError.ts +16 -0
- package/src/log/logger.ts +148 -0
- package/src/mapSet/customSet.ts +91 -0
- package/src/mapSet/extendMap.ts +40 -0
- package/src/misc/assertNotNull.ts +21 -0
- package/src/object/definePublicConstant.ts +10 -0
- package/src/object/initOnRead.ts +27 -0
- package/src/object/objectPath.ts +10 -0
- package/src/object/objectSame.ts +52 -0
- package/src/path/isAbsolute.ts +11 -0
- package/src/path/normalizePath.ts +8 -0
- package/src/path/pathArray.ts +42 -0
- package/src/platform/globalObject.ts +22 -0
- package/src/platform/globalSingleton.ts +82 -0
- package/src/platform/globalSymbol.ts +36 -0
- package/src/platform/os.ts +46 -0
- package/src/promise/awaitIterator.ts +19 -0
- package/src/promise/finishAllPromise.ts +50 -0
- package/src/promise/promiseBool.ts +10 -0
- package/src/promise/promisePool.ts +40 -0
- package/src/promise/timeoutPromisePool.ts +22 -0
- package/src/reflection/classes/hookClass.ts +47 -0
- package/src/reflection/classes/singleton.ts +33 -0
- package/src/reflection/methods/bind.ts +30 -0
- package/src/reflection/methods/initOnRead.ts +11 -0
- package/src/reflection/methods/memorize.ts +33 -0
- package/src/string/castCase.ts +44 -0
- package/src/string/concatType.generated.ts +265 -0
- package/src/string/concatType.generator.ts +31 -0
- package/src/string/escapeRegexp.ts +4 -0
- package/src/string/pad2.ts +11 -0
- package/src/string/sizeString.ts +52 -0
- package/src/tsconfig.json +14 -0
- package/src/typingHelper/deep.partial.ts +16 -0
- package/src/typingHelper/deep.readonly.ts +16 -0
- package/src/typingHelper/deep.required.ts +16 -0
- package/src/typingHelper/deep.writable.ts +16 -0
- package/src/typingHelper/literal.ts +1 -0
- package/docs/common.api.json +0 -21737
- package/docs/common.api.md +0 -1139
- package/docs/package-public.d.ts +0 -952
- package/docs/tsdoc-metadata.json +0 -11
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const memorizeValueSymbol = Symbol('@gongt/memorizeValue');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Decorate class method/getter
|
|
5
|
+
*
|
|
6
|
+
* remember first return value of method/getter, directlly return memorized value when call it again
|
|
7
|
+
*/
|
|
8
|
+
export const memo: MethodDecorator = <T>(
|
|
9
|
+
_target: Object,
|
|
10
|
+
propertyKey: string | symbol,
|
|
11
|
+
descriptor: TypedPropertyDescriptor<T>
|
|
12
|
+
) => {
|
|
13
|
+
const original: Function = (descriptor.value ? descriptor.value : descriptor.get) as any;
|
|
14
|
+
if (descriptor.set || typeof original !== 'function') {
|
|
15
|
+
throw new TypeError('@memo should only use on method, or getter. Not property and setter.');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (descriptor.get) {
|
|
19
|
+
descriptor.get = function memo_getter(this: any) {
|
|
20
|
+
const value = original.call(this, arguments);
|
|
21
|
+
Object.defineProperty(this, propertyKey, { value });
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
descriptor.value = function memo_method(this: any) {
|
|
26
|
+
const value = original.call(this, arguments);
|
|
27
|
+
Object.defineProperty(this, propertyKey, { value: () => value });
|
|
28
|
+
return value;
|
|
29
|
+
} as any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return descriptor;
|
|
33
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export function camelCase(str: string) {
|
|
3
|
+
return str.replace(/[-.\/_][a-z]/g, (s) => {
|
|
4
|
+
return s[1].toUpperCase();
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Uppercase first char
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export function ucfirst<T extends string>(str: T): Capitalize<T> {
|
|
13
|
+
return <any>(str[0].toUpperCase() + str.slice(1));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* lowercase first char
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export function lcfirst<T extends string>(str: T): Uncapitalize<T> {
|
|
21
|
+
return <any>(str[0].toLowerCase() + str.slice(1));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** @public */
|
|
25
|
+
export function linux_case(str: string) {
|
|
26
|
+
return str
|
|
27
|
+
.replace(/^[A-Z]/, (s) => {
|
|
28
|
+
return s.toLowerCase();
|
|
29
|
+
})
|
|
30
|
+
.replace(/[A-Z]/g, (s) => {
|
|
31
|
+
return '_' + s.toLowerCase();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @public */
|
|
36
|
+
export function linux_case_hyphen(str: string) {
|
|
37
|
+
return str
|
|
38
|
+
.replace(/^[A-Z]/, (s) => {
|
|
39
|
+
return s.toLowerCase();
|
|
40
|
+
})
|
|
41
|
+
.replace(/[A-Z]/g, (s) => {
|
|
42
|
+
return '-' + s.toLowerCase();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* GENERATED FILE, DO NOT MODIFY
|
|
6
|
+
* 这是生成的文件,千万不要修改
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export function concatStringType<T0 extends string>(
|
|
12
|
+
t0: T0
|
|
13
|
+
): `${T0}`;
|
|
14
|
+
export function concatStringType<T0 extends string, T1 extends string>(
|
|
15
|
+
t0: T0,
|
|
16
|
+
t1: T1
|
|
17
|
+
): `${T0}${T1}`;
|
|
18
|
+
export function concatStringType<T0 extends string, T1 extends string, T2 extends string>(
|
|
19
|
+
t0: T0,
|
|
20
|
+
t1: T1,
|
|
21
|
+
t2: T2
|
|
22
|
+
): `${T0}${T1}${T2}`;
|
|
23
|
+
export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string>(
|
|
24
|
+
t0: T0,
|
|
25
|
+
t1: T1,
|
|
26
|
+
t2: T2,
|
|
27
|
+
t3: T3
|
|
28
|
+
): `${T0}${T1}${T2}${T3}`;
|
|
29
|
+
export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string>(
|
|
30
|
+
t0: T0,
|
|
31
|
+
t1: T1,
|
|
32
|
+
t2: T2,
|
|
33
|
+
t3: T3,
|
|
34
|
+
t4: T4
|
|
35
|
+
): `${T0}${T1}${T2}${T3}${T4}`;
|
|
36
|
+
export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string>(
|
|
37
|
+
t0: T0,
|
|
38
|
+
t1: T1,
|
|
39
|
+
t2: T2,
|
|
40
|
+
t3: T3,
|
|
41
|
+
t4: T4,
|
|
42
|
+
t5: T5
|
|
43
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}`;
|
|
44
|
+
export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string>(
|
|
45
|
+
t0: T0,
|
|
46
|
+
t1: T1,
|
|
47
|
+
t2: T2,
|
|
48
|
+
t3: T3,
|
|
49
|
+
t4: T4,
|
|
50
|
+
t5: T5,
|
|
51
|
+
t6: T6
|
|
52
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}`;
|
|
53
|
+
export 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>(
|
|
54
|
+
t0: T0,
|
|
55
|
+
t1: T1,
|
|
56
|
+
t2: T2,
|
|
57
|
+
t3: T3,
|
|
58
|
+
t4: T4,
|
|
59
|
+
t5: T5,
|
|
60
|
+
t6: T6,
|
|
61
|
+
t7: T7
|
|
62
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}`;
|
|
63
|
+
export 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>(
|
|
64
|
+
t0: T0,
|
|
65
|
+
t1: T1,
|
|
66
|
+
t2: T2,
|
|
67
|
+
t3: T3,
|
|
68
|
+
t4: T4,
|
|
69
|
+
t5: T5,
|
|
70
|
+
t6: T6,
|
|
71
|
+
t7: T7,
|
|
72
|
+
t8: T8
|
|
73
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}`;
|
|
74
|
+
export 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>(
|
|
75
|
+
t0: T0,
|
|
76
|
+
t1: T1,
|
|
77
|
+
t2: T2,
|
|
78
|
+
t3: T3,
|
|
79
|
+
t4: T4,
|
|
80
|
+
t5: T5,
|
|
81
|
+
t6: T6,
|
|
82
|
+
t7: T7,
|
|
83
|
+
t8: T8,
|
|
84
|
+
t9: T9
|
|
85
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}`;
|
|
86
|
+
export 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>(
|
|
87
|
+
t0: T0,
|
|
88
|
+
t1: T1,
|
|
89
|
+
t2: T2,
|
|
90
|
+
t3: T3,
|
|
91
|
+
t4: T4,
|
|
92
|
+
t5: T5,
|
|
93
|
+
t6: T6,
|
|
94
|
+
t7: T7,
|
|
95
|
+
t8: T8,
|
|
96
|
+
t9: T9,
|
|
97
|
+
t10: T10
|
|
98
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}`;
|
|
99
|
+
export 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>(
|
|
100
|
+
t0: T0,
|
|
101
|
+
t1: T1,
|
|
102
|
+
t2: T2,
|
|
103
|
+
t3: T3,
|
|
104
|
+
t4: T4,
|
|
105
|
+
t5: T5,
|
|
106
|
+
t6: T6,
|
|
107
|
+
t7: T7,
|
|
108
|
+
t8: T8,
|
|
109
|
+
t9: T9,
|
|
110
|
+
t10: T10,
|
|
111
|
+
t11: T11
|
|
112
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}`;
|
|
113
|
+
export 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>(
|
|
114
|
+
t0: T0,
|
|
115
|
+
t1: T1,
|
|
116
|
+
t2: T2,
|
|
117
|
+
t3: T3,
|
|
118
|
+
t4: T4,
|
|
119
|
+
t5: T5,
|
|
120
|
+
t6: T6,
|
|
121
|
+
t7: T7,
|
|
122
|
+
t8: T8,
|
|
123
|
+
t9: T9,
|
|
124
|
+
t10: T10,
|
|
125
|
+
t11: T11,
|
|
126
|
+
t12: T12
|
|
127
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}`;
|
|
128
|
+
export 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>(
|
|
129
|
+
t0: T0,
|
|
130
|
+
t1: T1,
|
|
131
|
+
t2: T2,
|
|
132
|
+
t3: T3,
|
|
133
|
+
t4: T4,
|
|
134
|
+
t5: T5,
|
|
135
|
+
t6: T6,
|
|
136
|
+
t7: T7,
|
|
137
|
+
t8: T8,
|
|
138
|
+
t9: T9,
|
|
139
|
+
t10: T10,
|
|
140
|
+
t11: T11,
|
|
141
|
+
t12: T12,
|
|
142
|
+
t13: T13
|
|
143
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}`;
|
|
144
|
+
export 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>(
|
|
145
|
+
t0: T0,
|
|
146
|
+
t1: T1,
|
|
147
|
+
t2: T2,
|
|
148
|
+
t3: T3,
|
|
149
|
+
t4: T4,
|
|
150
|
+
t5: T5,
|
|
151
|
+
t6: T6,
|
|
152
|
+
t7: T7,
|
|
153
|
+
t8: T8,
|
|
154
|
+
t9: T9,
|
|
155
|
+
t10: T10,
|
|
156
|
+
t11: T11,
|
|
157
|
+
t12: T12,
|
|
158
|
+
t13: T13,
|
|
159
|
+
t14: T14
|
|
160
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}`;
|
|
161
|
+
export 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>(
|
|
162
|
+
t0: T0,
|
|
163
|
+
t1: T1,
|
|
164
|
+
t2: T2,
|
|
165
|
+
t3: T3,
|
|
166
|
+
t4: T4,
|
|
167
|
+
t5: T5,
|
|
168
|
+
t6: T6,
|
|
169
|
+
t7: T7,
|
|
170
|
+
t8: T8,
|
|
171
|
+
t9: T9,
|
|
172
|
+
t10: T10,
|
|
173
|
+
t11: T11,
|
|
174
|
+
t12: T12,
|
|
175
|
+
t13: T13,
|
|
176
|
+
t14: T14,
|
|
177
|
+
t15: T15
|
|
178
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}`;
|
|
179
|
+
export 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>(
|
|
180
|
+
t0: T0,
|
|
181
|
+
t1: T1,
|
|
182
|
+
t2: T2,
|
|
183
|
+
t3: T3,
|
|
184
|
+
t4: T4,
|
|
185
|
+
t5: T5,
|
|
186
|
+
t6: T6,
|
|
187
|
+
t7: T7,
|
|
188
|
+
t8: T8,
|
|
189
|
+
t9: T9,
|
|
190
|
+
t10: T10,
|
|
191
|
+
t11: T11,
|
|
192
|
+
t12: T12,
|
|
193
|
+
t13: T13,
|
|
194
|
+
t14: T14,
|
|
195
|
+
t15: T15,
|
|
196
|
+
t16: T16
|
|
197
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}`;
|
|
198
|
+
export 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>(
|
|
199
|
+
t0: T0,
|
|
200
|
+
t1: T1,
|
|
201
|
+
t2: T2,
|
|
202
|
+
t3: T3,
|
|
203
|
+
t4: T4,
|
|
204
|
+
t5: T5,
|
|
205
|
+
t6: T6,
|
|
206
|
+
t7: T7,
|
|
207
|
+
t8: T8,
|
|
208
|
+
t9: T9,
|
|
209
|
+
t10: T10,
|
|
210
|
+
t11: T11,
|
|
211
|
+
t12: T12,
|
|
212
|
+
t13: T13,
|
|
213
|
+
t14: T14,
|
|
214
|
+
t15: T15,
|
|
215
|
+
t16: T16,
|
|
216
|
+
t17: T17
|
|
217
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}`;
|
|
218
|
+
export 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>(
|
|
219
|
+
t0: T0,
|
|
220
|
+
t1: T1,
|
|
221
|
+
t2: T2,
|
|
222
|
+
t3: T3,
|
|
223
|
+
t4: T4,
|
|
224
|
+
t5: T5,
|
|
225
|
+
t6: T6,
|
|
226
|
+
t7: T7,
|
|
227
|
+
t8: T8,
|
|
228
|
+
t9: T9,
|
|
229
|
+
t10: T10,
|
|
230
|
+
t11: T11,
|
|
231
|
+
t12: T12,
|
|
232
|
+
t13: T13,
|
|
233
|
+
t14: T14,
|
|
234
|
+
t15: T15,
|
|
235
|
+
t16: T16,
|
|
236
|
+
t17: T17,
|
|
237
|
+
t18: T18
|
|
238
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}${T18}`;
|
|
239
|
+
export 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>(
|
|
240
|
+
t0: T0,
|
|
241
|
+
t1: T1,
|
|
242
|
+
t2: T2,
|
|
243
|
+
t3: T3,
|
|
244
|
+
t4: T4,
|
|
245
|
+
t5: T5,
|
|
246
|
+
t6: T6,
|
|
247
|
+
t7: T7,
|
|
248
|
+
t8: T8,
|
|
249
|
+
t9: T9,
|
|
250
|
+
t10: T10,
|
|
251
|
+
t11: T11,
|
|
252
|
+
t12: T12,
|
|
253
|
+
t13: T13,
|
|
254
|
+
t14: T14,
|
|
255
|
+
t15: T15,
|
|
256
|
+
t16: T16,
|
|
257
|
+
t17: T17,
|
|
258
|
+
t18: T18,
|
|
259
|
+
t19: T19
|
|
260
|
+
): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}${T18}${T19}`;
|
|
261
|
+
|
|
262
|
+
/* copy */
|
|
263
|
+
export function concatStringType(a: string[]): string {
|
|
264
|
+
return a.join('');
|
|
265
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
|
|
3
|
+
/* copy */
|
|
4
|
+
export function concatStringType(a: string[]): string {
|
|
5
|
+
return a.join('');
|
|
6
|
+
}
|
|
7
|
+
/* copy end */
|
|
8
|
+
|
|
9
|
+
export function generate() {
|
|
10
|
+
let content = '';
|
|
11
|
+
const typeList = [];
|
|
12
|
+
const argList = [];
|
|
13
|
+
const returnList = [];
|
|
14
|
+
for (let i = 0; i < 20; i++) {
|
|
15
|
+
typeList.push(`T${i} extends string`);
|
|
16
|
+
argList.push(`t${i}: T${i}`);
|
|
17
|
+
returnList.push(`\${T${i}}`);
|
|
18
|
+
|
|
19
|
+
const type = typeList.join(', ');
|
|
20
|
+
const arg = argList.join(',\n\t');
|
|
21
|
+
const ret = returnList.join('');
|
|
22
|
+
content += `export function concatStringType<${type}>(\n\t${arg}\n): \`${ret}\`;\n`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const full: string = readFileSync(__filename, 'utf-8');
|
|
26
|
+
const lines = full.split('\n');
|
|
27
|
+
content += '\n';
|
|
28
|
+
content += lines.slice(lines.indexOf('/* copy */'), lines.indexOf('/* copy end */')).join('\n');
|
|
29
|
+
|
|
30
|
+
return content;
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert bytes to largest unit, with SI prefix unit (1000), eg: 211.293GB
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export function humanSizeSI(bytes: number, fixed = 2) {
|
|
6
|
+
if (bytes < 0) {
|
|
7
|
+
return '<0B';
|
|
8
|
+
} else if (bytes < 1000) {
|
|
9
|
+
return bytes + 'B';
|
|
10
|
+
} else if (bytes < 1000000) {
|
|
11
|
+
return (bytes / 1000).toFixed(fixed) + 'KiB';
|
|
12
|
+
} else if (bytes < 1000000000) {
|
|
13
|
+
return (bytes / 1000000).toFixed(fixed) + 'MiB';
|
|
14
|
+
} else if (bytes < 1000000000000) {
|
|
15
|
+
return (bytes / 1000000000).toFixed(fixed) + 'GiB';
|
|
16
|
+
} else if (bytes < 1000000000000000) {
|
|
17
|
+
return (bytes / 1000000000000).toFixed(fixed) + 'TiB';
|
|
18
|
+
} else {
|
|
19
|
+
return (bytes / 1000000000000000).toFixed(fixed) + 'PiB';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Convert bytes to largest unit, with binary prefix unit (1024), eg: 211.293GiB
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export function humanSize(bytes: number, fixed = 2) {
|
|
28
|
+
if (bytes < 0) {
|
|
29
|
+
return '<0B';
|
|
30
|
+
} else if (bytes < 1024) {
|
|
31
|
+
return bytes + 'B';
|
|
32
|
+
} else if (bytes < 1048576) {
|
|
33
|
+
// 1024 * 1024
|
|
34
|
+
return (bytes / 1024).toFixed(fixed) + 'KiB';
|
|
35
|
+
} else if (bytes < 1073741824) {
|
|
36
|
+
// 1024 * 1024 * 1024
|
|
37
|
+
return (bytes / 1048576).toFixed(fixed) + 'MiB';
|
|
38
|
+
} else if (bytes < 1099511627776) {
|
|
39
|
+
// 1024 * 1024 * 1024 * 1024
|
|
40
|
+
return (bytes / 1073741824).toFixed(fixed) + 'GiB';
|
|
41
|
+
} else if (bytes < 1125899906842624) {
|
|
42
|
+
// 1024 * 1024 * 1024 * 1024 * 1024
|
|
43
|
+
return (bytes / 1099511627776).toFixed(fixed) + 'TiB';
|
|
44
|
+
} else {
|
|
45
|
+
return (bytes / 1125899906842624).toFixed(fixed) + 'PiB';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @deprecated */
|
|
50
|
+
export function humanSpeed(bps: number) {
|
|
51
|
+
return humanSize(bps) + '/s';
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "local-rig/profiles/default/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"typeRoots": ["./node_modules/@types", "./node_modules"],
|
|
5
|
+
"tsBuildInfoFile": "../temp/tsbuildinfo.json",
|
|
6
|
+
"outDir": "../lib",
|
|
7
|
+
"declarationDir": "../temp/dts",
|
|
8
|
+
"rootDir": "./",
|
|
9
|
+
|
|
10
|
+
"types": ["@idlebox/itypes"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["**/*.ts"],
|
|
13
|
+
"exclude": ["**/*.generator.ts"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Primitive } from './literal';
|
|
2
|
+
|
|
3
|
+
export type DeepPartial<T> = T extends Primitive
|
|
4
|
+
? T
|
|
5
|
+
: T extends ReadonlyArray<infer U>
|
|
6
|
+
? DeepPartialArray<U>
|
|
7
|
+
: T extends ReadonlyMap<infer K, infer V>
|
|
8
|
+
? DeepPartialMap<K, V>
|
|
9
|
+
: T extends ReadonlySet<infer M>
|
|
10
|
+
? DeepPartialSet<M>
|
|
11
|
+
: DeepPartialObject<T>;
|
|
12
|
+
|
|
13
|
+
type DeepPartialArray<T> = Array<DeepPartial<T>>;
|
|
14
|
+
type DeepPartialMap<K, V> = Map<DeepPartial<K>, DeepPartial<V>>;
|
|
15
|
+
type DeepPartialSet<T> = Set<DeepPartial<T>>;
|
|
16
|
+
type DeepPartialObject<T> = { [K in keyof T]?: DeepPartial<T[K]> };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Primitive } from './literal';
|
|
2
|
+
|
|
3
|
+
export type DeepReadonly<T> = T extends Primitive
|
|
4
|
+
? T
|
|
5
|
+
: T extends Array<infer U>
|
|
6
|
+
? DeepReadonlyArray<U>
|
|
7
|
+
: T extends Map<infer K, infer V>
|
|
8
|
+
? DeepReadonlyMap<K, V>
|
|
9
|
+
: T extends Set<infer M>
|
|
10
|
+
? DeepReadonlySet<M>
|
|
11
|
+
: DeepReadonlyObject<T>;
|
|
12
|
+
|
|
13
|
+
type DeepReadonlyArray<T> = ReadonlyArray<DeepReadonly<T>>;
|
|
14
|
+
type DeepReadonlyMap<K, V> = ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>;
|
|
15
|
+
type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
|
|
16
|
+
type DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Primitive } from './literal';
|
|
2
|
+
|
|
3
|
+
export type DeepNonNullable<T> = T extends Primitive
|
|
4
|
+
? T
|
|
5
|
+
: T extends ReadonlyArray<infer U> | Array<infer U>
|
|
6
|
+
? DeepNonNullableArray<U>
|
|
7
|
+
: T extends ReadonlyMap<infer K, infer V> | Map<infer K, infer V>
|
|
8
|
+
? DeepNonNullableMap<K, V>
|
|
9
|
+
: T extends ReadonlySet<infer M>
|
|
10
|
+
? DeepNonNullableSet<M>
|
|
11
|
+
: DeepNonNullableObject<T>;
|
|
12
|
+
|
|
13
|
+
type DeepNonNullableArray<T> = Array<DeepNonNullable<T>>;
|
|
14
|
+
type DeepNonNullableMap<K, V> = Map<DeepNonNullable<K>, DeepNonNullable<V>>;
|
|
15
|
+
type DeepNonNullableSet<T> = Set<DeepNonNullable<T>>;
|
|
16
|
+
type DeepNonNullableObject<T> = { [K in keyof T]-?: NonNullable<T[K]> };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Primitive } from './literal';
|
|
2
|
+
|
|
3
|
+
export type DeepWriteable<T> = T extends Primitive
|
|
4
|
+
? T
|
|
5
|
+
: T extends ReadonlyArray<infer U>
|
|
6
|
+
? DeepWriteableArray<U>
|
|
7
|
+
: T extends ReadonlyMap<infer K, infer V>
|
|
8
|
+
? DeepWriteableMap<K, V>
|
|
9
|
+
: T extends ReadonlySet<infer M>
|
|
10
|
+
? DeepWriteableSet<M>
|
|
11
|
+
: DeepWriteableObject<T>;
|
|
12
|
+
|
|
13
|
+
type DeepWriteableArray<T> = Array<DeepWriteable<T>>;
|
|
14
|
+
type DeepWriteableMap<K, V> = Map<DeepWriteable<K>, DeepWriteable<V>>;
|
|
15
|
+
type DeepWriteableSet<T> = Set<DeepWriteable<T>>;
|
|
16
|
+
type DeepWriteableObject<T> = { -readonly [K in keyof T]: DeepWriteable<T[K]> };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Primitive = undefined | null | boolean | string | number | Function | bigint;
|