type-tls 2.2.0 → 2.4.0

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 (69) hide show
  1. package/README.md +81 -0
  2. package/dist/async.d.ts +28 -0
  3. package/dist/base.d.ts +184 -0
  4. package/dist/buffer.d.ts +1 -0
  5. package/dist/extend.d.ts +86 -0
  6. package/dist/function.d.ts +49 -0
  7. package/dist/index.d.ts +6 -166
  8. package/dist/member.d.ts +16 -0
  9. package/dist/mixin.d.ts +96 -0
  10. package/dist/tsdoc-metadata.json +11 -0
  11. package/dist/type-tls.d.ts +505 -0
  12. package/dist/type-tls.es.js +154 -135
  13. package/dist/type-tls.iife.js +1 -0
  14. package/dist/type-tls.umd.js +1 -1
  15. package/doc/index.md +12 -0
  16. package/doc/type-tls.anyfunction.md +13 -0
  17. package/doc/type-tls.classtype._new_.md +22 -0
  18. package/doc/type-tls.classtype.md +20 -0
  19. package/doc/type-tls.createdefinemixin.md +23 -0
  20. package/doc/type-tls.createextendtarget.md +30 -0
  21. package/doc/type-tls.createmixintarget.md +30 -0
  22. package/doc/type-tls.createtargetextend.md +30 -0
  23. package/doc/type-tls.createtargetmixin.md +30 -0
  24. package/doc/type-tls.defineextend.md +35 -0
  25. package/doc/type-tls.definemixin.md +31 -0
  26. package/doc/type-tls.exacttype.md +34 -0
  27. package/doc/type-tls.exacttypename.md +34 -0
  28. package/doc/type-tls.extendtarget.md +31 -0
  29. package/doc/type-tls.getexacttypenameof.md +26 -0
  30. package/doc/type-tls.getexacttypeof.md +26 -0
  31. package/doc/type-tls.getnameoftype.md +24 -0
  32. package/doc/type-tls.gettypebyname.md +24 -0
  33. package/doc/type-tls.gettypenameof.md +30 -0
  34. package/doc/type-tls.gettypeof.md +38 -0
  35. package/doc/type-tls.isanonymousfunction.md +35 -0
  36. package/doc/type-tls.isarraylike.md +25 -0
  37. package/doc/type-tls.isarrowfunction.md +24 -0
  38. package/doc/type-tls.isasyncfunction.md +28 -0
  39. package/doc/type-tls.isasyncgeneratorfunction.md +24 -0
  40. package/doc/type-tls.isbasetype.md +28 -0
  41. package/doc/type-tls.isgeneratorfunction.md +28 -0
  42. package/doc/type-tls.isidentifier.md +24 -0
  43. package/doc/type-tls.isiterable.md +24 -0
  44. package/doc/type-tls.isiterator.md +24 -0
  45. package/doc/type-tls.isobject.md +30 -0
  46. package/doc/type-tls.loosetype.md +13 -0
  47. package/doc/type-tls.loosetypename.md +13 -0
  48. package/doc/type-tls.md +70 -0
  49. package/doc/type-tls.methodparams.md +15 -0
  50. package/doc/type-tls.methodreturntype.md +15 -0
  51. package/doc/type-tls.mixin_4.md +33 -0
  52. package/doc/type-tls.mixintarget.md +31 -0
  53. package/doc/type-tls.optional.md +13 -0
  54. package/doc/type-tls.optionalboolean.md +15 -0
  55. package/doc/type-tls.privatememberofextend._constructor.md +22 -0
  56. package/doc/type-tls.privatememberofextend.md +20 -0
  57. package/doc/type-tls.replace.md +13 -0
  58. package/doc/type-tls.replacenull.md +15 -0
  59. package/doc/type-tls.replaceundefined.md +15 -0
  60. package/doc/type-tls.replacevoid.md +15 -0
  61. package/doc/type-tls.resolvedata.md +18 -0
  62. package/doc/type-tls.targetextend.md +31 -0
  63. package/doc/type-tls.targetmixin.md +31 -0
  64. package/doc/type-tls.typeofreturntype.md +13 -0
  65. package/doc/type-tls.waitasyncable.md +30 -0
  66. package/doc/type-tls.waitasyncablecallback.md +15 -0
  67. package/doc/type-tls.waitasyncablereturn.md +13 -0
  68. package/package.json +27 -22
  69. package/dist/type-tls.cjs.js +0 -166
@@ -0,0 +1,96 @@
1
+ /**
2
+ * 混合
3
+ * @internal
4
+ */
5
+ export declare function mixin<T, S>(target: T, source: S): T & S;
6
+ /**
7
+ * 混合
8
+ * @internal
9
+ */
10
+ export declare function mixin<T, S1, S2>(target: T, source1: S1, source2: S2): T & S1 & S2;
11
+ /**
12
+ * 混合
13
+ * @internal
14
+ */
15
+ export declare function mixin<T, S1, S2, S3>(target: T, source1: S1, source2: S2, source3: S3): T & S1 & S2 & S3;
16
+ /**
17
+ * 混合
18
+ * @internal
19
+ */
20
+ export declare function mixin<T, S1, S2, S3, S4>(target: T, source1: S1, source2: S2, source3: S3, source4: S3): T & S1 & S2 & S3 & S4;
21
+ /**
22
+ * 混合
23
+ *
24
+ * @remarks
25
+ * 将 source 的所有成员混入 target 对象中。
26
+ *
27
+ * 与 `Object.assign()` 的功能类似,不同的是 `mixin()` 会在 target 对象中 保持 source 对象属性的 PropertyDescriptors
28
+ *
29
+ * @param target - 目标对象,所有 源对象 的属性都要被混入进到 目标对象中
30
+ * @param sources - 源对象,所有 源对象 的属性都要被混入进到 目标对象中
31
+ * @returns 混入后的 target
32
+ */
33
+ export declare function mixin(target: any, ...sources: any[]): any;
34
+ /**
35
+ * 定义混合的类型便利函数
36
+ *
37
+ * @remarks
38
+ * 它会更改 mixin 中方法的this指向为 target & mixin,不会真的执行混合操作
39
+ *
40
+ * @param target - 混合的目标,用作 this 的类型
41
+ * @param mixin - 混合对象,会自动更改其this的类型
42
+ * @returns 返回注入了 this 类型的 mixin 对象本身
43
+ */
44
+ export declare function defineMixin<T, M>(target: T, mixin: M & ThisType<T & M>): M & ThisType<T & M>;
45
+ /**
46
+ * 创建定义混合的类型便利函数
47
+ *
48
+ * @remarks
49
+ * 它返回的便利函数的功能与 {@link defineMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
50
+ *
51
+ * @returns 可以用于 定义混合的 类型便利函数
52
+ */
53
+ export declare function createDefineMixin<T>(): <M>(target: T, mixin: M & ThisType<T & M>) => M & ThisType<T & M>;
54
+ /**
55
+ * 混合目标
56
+ *
57
+ * @remarks
58
+ * 与 {@link defineMixin} 的区别是:`targetMixin` 会执行对 target 的混合操作,而 {@link defineMixin} 不会
59
+ *
60
+ *
61
+ * @param target - 混合的目标,用作 this 的类型
62
+ * @param m - 混合对象,会自动更改其this的类型
63
+ * @returns 返回注入了 this 类型的 mixin 对象本身
64
+ */
65
+ export declare function targetMixin<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M>;
66
+ /**
67
+ * 创建用于混合目标的便捷函数
68
+ *
69
+ * @remarks
70
+ * 它返回的便利函数的功能与 {@link targetMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
71
+ *
72
+ * @param target - 混合的目标,用作 this 的类型
73
+ * @returns 可以用于 混合目标 的便利函数
74
+ */
75
+ export declare function createTargetMixin<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M>;
76
+ /**
77
+ * 混合目标
78
+ *
79
+ * @remarks
80
+ * 会执行对 CEarth 类的扩展操作。
81
+ * 与 {@link targetMixin} 的区别仅仅是返回类型不一样。
82
+ *
83
+ * @param target - 混合的目标,用作 this 的类型
84
+ * @param m - 混合对象,会自动更改其this的类型
85
+ * @returns 返回混合后的 target 对象
86
+ */
87
+ export declare function mixinTarget<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M> & T;
88
+ /**
89
+ * 创建用于混合目标工具函数
90
+ *
91
+ * @remarks
92
+ * 它返回的便利函数的功能与 {@link mixinTarget} 的功能一样,唯一区别是不再需要接收 target 参数了
93
+ *
94
+ * @returns 可以用于 混合目标 的便利函数
95
+ */
96
+ export declare function createMixinTarget<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M> & T;
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.28.3"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,505 @@
1
+ /**
2
+ * 表示任意的函数类型
3
+ */
4
+ export declare type AnyFunction = (...args: any) => any;
5
+
6
+ /**
7
+ * 类的类型、构造函数的类型
8
+ *
9
+ * @typeParam Arg - 构建函数的参数类型
10
+ * @typeParam Instance - 构建函数的返回的实例类型
11
+ */
12
+ export declare interface ClassType<Arg extends any[] = any[], Instance = any> {
13
+ new (...args: Arg): Instance;
14
+ }
15
+
16
+ /**
17
+ * 创建定义混合的类型便利函数
18
+ *
19
+ * @remarks
20
+ * 它返回的便利函数的功能与 {@link defineMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
21
+ *
22
+ * @returns 可以用于 定义混合的 类型便利函数
23
+ */
24
+ export declare function createDefineMixin<T>(): <M>(target: T, mixin: M & ThisType<T & M>) => M & ThisType<T & M>;
25
+
26
+ /**
27
+ * 创建用于扩展目标工具函数
28
+ *
29
+ * @remarks
30
+ * 它返回的便利函数的功能与 {@link extendTarget} 的功能一样,唯一区别是不再需要接收 cla 参数了
31
+ *
32
+ * @param cla - 扩展的目标,也用作 this 的类型
33
+ * @returns 可以用于 扩展目标 的便利函数
34
+ */
35
+ export declare function createExtendTarget<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>) => ClassType<ConstructorParameters<C>, E & ThisType<InstanceType<C> & E>>;
36
+
37
+ /**
38
+ * 创建用于混合目标工具函数
39
+ *
40
+ * @remarks
41
+ * 它返回的便利函数的功能与 {@link mixinTarget} 的功能一样,唯一区别是不再需要接收 target 参数了
42
+ *
43
+ * @returns 可以用于 混合目标 的便利函数
44
+ */
45
+ export declare function createMixinTarget<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M> & T;
46
+
47
+ /**
48
+ * 创建用于扩展目标的便捷函数
49
+ *
50
+ * @remarks
51
+ * 它返回的便利函数的功能与 {@link targetExtend} 的功能一样,唯一区别是不再需要接收 cla 参数了
52
+ *
53
+ * @param cla - 扩展的目标,也用作 this 的类型
54
+ * @returns 可以用于 扩展目标 的便利函数
55
+ */
56
+ export declare function createTargetExtend<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>) => E & ThisType<C & E>;
57
+
58
+ /**
59
+ * 创建用于混合目标的便捷函数
60
+ *
61
+ * @remarks
62
+ * 它返回的便利函数的功能与 {@link targetMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
63
+ *
64
+ * @param target - 混合的目标,用作 this 的类型
65
+ * @returns 可以用于 混合目标 的便利函数
66
+ */
67
+ export declare function createTargetMixin<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M>;
68
+
69
+ /**
70
+ * 定义扩展的类型便利函数
71
+ *
72
+ * @remarks
73
+ * 它会更改 ext 中方法的this指向为 cla & ext,不会真的执行扩展操作。
74
+ *
75
+ * 其中 ext._constructor 会被保存在 cla._constructors 属性中,它是一个数组。
76
+ *
77
+ * cla 需要在自己的构建函数中逐个调用 cla._constructors 中的函数
78
+ *
79
+ * @param cla - 扩展的目标,用作 this 的类型
80
+ * @param ext - 描述扩展内容的对象,会自动更改其this的类型
81
+ * @returns 返回注入了 this 类型的 ext 对象本身
82
+ */
83
+ export declare function defineExtend<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): E & ThisType<C & E>;
84
+
85
+ /**
86
+ * 定义混合的类型便利函数
87
+ *
88
+ * @remarks
89
+ * 它会更改 mixin 中方法的this指向为 target & mixin,不会真的执行混合操作
90
+ *
91
+ * @param target - 混合的目标,用作 this 的类型
92
+ * @param mixin - 混合对象,会自动更改其this的类型
93
+ * @returns 返回注入了 this 类型的 mixin 对象本身
94
+ */
95
+ export declare function defineMixin<T, M>(target: T, mixin: M & ThisType<T & M>): M & ThisType<T & M>;
96
+
97
+ /**
98
+ * 精确类型
99
+ *
100
+ * @remarks
101
+ * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
102
+ * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
103
+ * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
104
+ * 但,对于 undefined 和 null 会返回其自身值(即 undefined 和 null)作为类型值
105
+ *
106
+ * 各种类型的值 与 该方法的返回值 的映射如下:
107
+ * ```
108
+ * undefined :undefined
109
+ * null : null
110
+ * string : "string"
111
+ * number : "number"
112
+ * bigint : "bigint"
113
+ * boolean : "boolean"
114
+ * symbol : "symbol"
115
+ * function : Function
116
+ * 没有原型的对象(如:通过 `Object.create(null)` 创建的对象) : "object"
117
+ * 其它任何类型的实例 : 返回该实例的构造函数
118
+ * ```
119
+ */
120
+ export declare type ExactType = LooseType | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
121
+
122
+ /**
123
+ * 精确类型的字符串表示
124
+ *
125
+ * @remarks
126
+ * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
127
+ * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
128
+ * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
129
+ * 但,对于 null 会返回 "null"
130
+ *
131
+ * 各种类型的值 与 该方法的返回值 的映射如下:
132
+ * ```
133
+ * undefined :"undefined"
134
+ * null : "null"
135
+ * function : "Function"
136
+ * string : "string"
137
+ * number : "number"
138
+ * bigint : "bigint"
139
+ * boolean : "boolean"
140
+ * symbol : "symbol"
141
+ * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
142
+ * 其它任何类型的实例 : 返回该实例的构造函数的名字
143
+ * ```
144
+ */
145
+ export declare type ExactTypeName = LooseTypeName | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
146
+
147
+ /**
148
+ * 扩展目标
149
+ *
150
+ * @remarks
151
+ * 会执行对 CEarth 类的扩展操作。
152
+ * 与 {@link targetExtend} 的区别仅仅是返回类型不一样。
153
+ *
154
+ * @param cla - 扩展的目标,也用作 this 的类型
155
+ * @param ext - 扩展对象,会自动更改其this的类型
156
+ * @returns 返回扩展后的 cla 对象
157
+ */
158
+ export declare function extendTarget<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): ClassType<ConstructorParameters<C>, E & ThisType<InstanceType<C> & E>>;
159
+
160
+ /**
161
+ * 获取 inst 的精确类型的字符串表示
162
+ * @param inst
163
+ * @returns inst 的类型字符串
164
+ */
165
+ export declare function getExactTypeNameOf(inst: any): ExactTypeName;
166
+
167
+ /**
168
+ * 获取 inst 的精确类型
169
+ * @param inst
170
+ * @returns inst 的类型
171
+ */
172
+ export declare function getExactTypeOf(inst: any): ExactType;
173
+
174
+ /**
175
+ * 获取 类型的字符串表示
176
+ *
177
+ * @param t - 一个 ExactType 类型的值
178
+ * @return t 的字符串表示的类型
179
+ */
180
+ export declare function getNameOfType(t: ExactType): ExactTypeName;
181
+
182
+ /**
183
+ * 根据类型的名字获取其对应的类
184
+ * @param typeName - 类型的名字
185
+ */
186
+ export declare function getTypeByName(typeName: string): Function | undefined;
187
+
188
+ /**
189
+ * 获取 inst 的类型字符串
190
+ *
191
+ * @remarks
192
+ * 注意:
193
+ * 本方法返回的结果如下:
194
+ * undefined :"undefined"
195
+ * null : "null"
196
+ * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
197
+ * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数 的函数名字
198
+ *
199
+ * @param inst
200
+ * @returns inst 的类型字符串
201
+ */
202
+ export declare function getTypeNameOf(inst: any): LooseTypeName;
203
+
204
+ /**
205
+ * 获取 inst 的宽松类型
206
+ *
207
+ * @remarks
208
+ * 注意:
209
+ * 本方法返回的结果如下:
210
+ * ```
211
+ * undefined :undefined
212
+ * null : null
213
+ * function : Function
214
+ * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
215
+ * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数
216
+ * ```
217
+ *
218
+ *
219
+ * @param inst
220
+ * @returns inst 的类型
221
+ */
222
+ export declare function getTypeOf(inst: any): LooseType;
223
+
224
+ /**
225
+ * 判断是否是匿名函数
226
+ *
227
+ * @remarks
228
+ * 判断函数在被定义时是否是通过匿名函数来定义的。
229
+ * 匿名函数是指声明函数时没有写名字的函数。
230
+ * 注意:即使是匿名函数,函数对象上的 name 属性也可能是有值的,因为 js解析器 会自动将 函数表达式函数变量的名字作为匿名函数的名字,如下:
231
+ * ```ts
232
+ * var funName = function(){};
233
+ * ```
234
+ * 其中的匿名函数对象的 name 属性的值会是 `funName`
235
+ *
236
+ * 如果 函数对象上的 name 属性的值为 `""`,函数一定是匿名函数。
237
+ */
238
+ export declare function isAnonymousFunction(fun: Function): boolean;
239
+
240
+ /**
241
+ * 判断 target 是否为 类数组对象
242
+ * @param target - 目标
243
+ * @returns
244
+ */
245
+ export declare function isArrayLike(target: any): boolean;
246
+
247
+ /**
248
+ * 判断函数是否是箭头函数
249
+ * @param fun - 被判断的函数
250
+ */
251
+ export declare function isArrowFunction(fun: Function): boolean;
252
+
253
+ /**
254
+ * 判断函数是否是 async 异步函数
255
+ * @remarks
256
+ * 异步函数 不包含 异步生成器函数 AsyncGeneratorFunction
257
+ * @param fun - 被判断的函数
258
+ */
259
+ export declare function isAsyncFunction(fun: Function): boolean;
260
+
261
+ /**
262
+ * 判断函数是否是异步生成器函数
263
+ * @param fun - 被判断的函数
264
+ */
265
+ export declare function isAsyncGeneratorFunction(fun: Function): boolean;
266
+
267
+ /**
268
+ * 判断 data 是否是 基本类型
269
+ * @remarks
270
+ * 基本类型 是指 那些不是 对象类型的类型,即,除了 object 和 function 类型以外,其它的都是基本类型,null 也算怎是 基本类型
271
+ * @param data - 任意类型的值
272
+ */
273
+ export declare function isBaseType(data: any): boolean;
274
+
275
+ /**
276
+ * 判断函数是否是生成器函数
277
+ *
278
+ * @remarks
279
+ * 生成器函数 不包含 异步生成器函数 AsyncGeneratorFunction
280
+ * @param fun - 被判断的函数
281
+ */
282
+ export declare function isGeneratorFunction(fun: Function): boolean;
283
+
284
+ /**
285
+ * 判断 code 是否是有校的 js 标识符
286
+ * @param code - 标识符的字符串
287
+ */
288
+ export declare function isIdentifier(code: string): boolean;
289
+
290
+ /**
291
+ * 判断 目标 是否是可迭代的对象,即 实现了 可迭代协议
292
+ * @param target - 目标
293
+ */
294
+ export declare function isIterable(target: any): boolean;
295
+
296
+ /**
297
+ * 判断 目标 是否是迭代器,即 实现了 迭代器协议
298
+ * @param target - 目标
299
+ */
300
+ export declare function isIterator(target: any): boolean;
301
+
302
+ /**
303
+ * 判断目标是否是对象类型
304
+ *
305
+ * @remarks
306
+ * 仅通过 target instanceof Object 判断是不行的,因为 对于 Object.create(null) 创建的对象 通过 ` Object.create(null) instanceof Object ` 来判断 返回的是 false
307
+ * 即:通过 Object.create(null) 创建的对象是不被 instanceof 认为是继续于 Object 的
308
+ *
309
+ * typeof null 也返回 "object"
310
+ *
311
+ * @param target : any 目标对象
312
+ */
313
+ export declare function isObject(target: any): boolean;
314
+
315
+ /**
316
+ * 宽松的类型
317
+ */
318
+ export declare type LooseType = undefined | null | Function | "object";
319
+
320
+ /**
321
+ * 宽松类型的字符串表示
322
+ */
323
+ export declare type LooseTypeName = "undefined" | "null" | "Function" | "object" | string;
324
+
325
+ /**
326
+ * 获取对象的方法的某个参数的类型
327
+ *
328
+ * @typeParam Obj - 对象
329
+ * @typeParam Method - 对象方法的名字
330
+ * @typeParam ParamIndex - 参数的索引个数
331
+ */
332
+ export declare type MethodParams<Obj, Method extends keyof Obj, ParamIndex extends number> = Obj[Method] extends AnyFunction ? Parameters<Obj[Method]>[ParamIndex] : never;
333
+
334
+ /**
335
+ * 获取对象的方法的返回的类型
336
+ *
337
+ * @typeParam Obj - 对象
338
+ * @typeParam Method - 对象方法的名字
339
+ */
340
+ export declare type MethodReturnType<Obj, Method extends keyof Obj> = Obj[Method] extends AnyFunction ? ReturnType<Obj[Method]> : never;
341
+
342
+ /**
343
+ * 混合
344
+ * @internal
345
+ */
346
+ export declare function mixin<T, S>(target: T, source: S): T & S;
347
+
348
+ /**
349
+ * 混合
350
+ * @internal
351
+ */
352
+ export declare function mixin<T, S1, S2>(target: T, source1: S1, source2: S2): T & S1 & S2;
353
+
354
+ /**
355
+ * 混合
356
+ * @internal
357
+ */
358
+ export declare function mixin<T, S1, S2, S3>(target: T, source1: S1, source2: S2, source3: S3): T & S1 & S2 & S3;
359
+
360
+ /**
361
+ * 混合
362
+ * @internal
363
+ */
364
+ export declare function mixin<T, S1, S2, S3, S4>(target: T, source1: S1, source2: S2, source3: S3, source4: S3): T & S1 & S2 & S3 & S4;
365
+
366
+ /**
367
+ * 混合
368
+ *
369
+ * @remarks
370
+ * 将 source 的所有成员混入 target 对象中。
371
+ *
372
+ * 与 `Object.assign()` 的功能类似,不同的是 `mixin()` 会在 target 对象中 保持 source 对象属性的 PropertyDescriptors
373
+ *
374
+ * @param target - 目标对象,所有 源对象 的属性都要被混入进到 目标对象中
375
+ * @param sources - 源对象,所有 源对象 的属性都要被混入进到 目标对象中
376
+ * @returns 混入后的 target
377
+ */
378
+ export declare function mixin(target: any, ...sources: any[]): any;
379
+
380
+ /**
381
+ * 混合目标
382
+ *
383
+ * @remarks
384
+ * 会执行对 CEarth 类的扩展操作。
385
+ * 与 {@link targetMixin} 的区别仅仅是返回类型不一样。
386
+ *
387
+ * @param target - 混合的目标,用作 this 的类型
388
+ * @param m - 混合对象,会自动更改其this的类型
389
+ * @returns 返回混合后的 target 对象
390
+ */
391
+ export declare function mixinTarget<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M> & T;
392
+
393
+ /**
394
+ * 将某个类型变为可选的类型
395
+ */
396
+ export declare type Optional<T> = T | null | undefined;
397
+
398
+ /**
399
+ * 可选的布尔类型
400
+ */
401
+ export declare type OptionalBoolean = Optional<boolean>;
402
+
403
+ /**
404
+ * 用于定义扩展选项中的私有成员
405
+ */
406
+ export declare interface PrivateMemberOfExtend<TargetType extends new (...args: any) => any> {
407
+ /**
408
+ * 扩展类中用于定义在创建实例时的初始化的方法
409
+ * @remarks
410
+ * 该方法会在创建实例时自动执行,并将构建函数接收到的参数透传给方方法。
411
+ *
412
+ * 注意:
413
+ * _constructor 会被保存在 目标类中的 _constructors 属性中,它是一个数组。
414
+ *
415
+ * 目标类 需要在自己的构建函数中逐个调用 cla._constructors 中的函数
416
+ *
417
+ * @param args
418
+ */
419
+ _constructor?: (...args: (TargetType extends new (...args: infer A) => any ? A : never)) => void;
420
+ }
421
+
422
+ /**
423
+ * 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType
424
+ */
425
+ export declare type Replace<SourType, MatchType, NewType> = SourType extends MatchType ? NewType : SourType;
426
+
427
+ /**
428
+ * 可将源类型 SourType 中的 null 替换为 新的类型 NewType
429
+ */
430
+ export declare type ReplaceNull<SourType, NewType> = Replace<SourType, null, NewType>;
431
+
432
+ /**
433
+ * 可将源类型 SourType 中的 undefined 替换为 新的类型 NewType
434
+ */
435
+ export declare type ReplaceUndefined<SourType, NewType> = Replace<SourType, undefined, NewType>;
436
+
437
+ /**
438
+ * 可将源类型 SourType 中的代表空的类型 void | undefined | null 替换为 新的类型 NewType
439
+ */
440
+ export declare type ReplaceVoid<SourType, NewType> = Replace<SourType, void | undefined | null, NewType>;
441
+
442
+ /**
443
+ * 获取 Promise 解决的类型的值
444
+ * @remarks
445
+ * 对于非 Promise 类型的值,返回原类型本身
446
+ */
447
+ export declare type ResolveData<P> = P extends Promise<infer D> ? D : P;
448
+
449
+ /**
450
+ * 扩展目标
451
+ *
452
+ * @remarks
453
+ * 与 {@link defineExtend} 的区别是:`targetExtend` 会执行对 cla 的扩展操作,而 {@link defineExtend} 不会
454
+ *
455
+ *
456
+ * @param cla - 扩展的目标,也用作 this 的类型
457
+ * @param ext - 扩展描述对象,会自动更改其this的类型
458
+ * @returns 返回注入了 this 类型的 ext 对象本身
459
+ */
460
+ export declare function targetExtend<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): E & ThisType<InstanceType<C> & E>;
461
+
462
+ /**
463
+ * 混合目标
464
+ *
465
+ * @remarks
466
+ * 与 {@link defineMixin} 的区别是:`targetMixin` 会执行对 target 的混合操作,而 {@link defineMixin} 不会
467
+ *
468
+ *
469
+ * @param target - 混合的目标,用作 this 的类型
470
+ * @param m - 混合对象,会自动更改其this的类型
471
+ * @returns 返回注入了 this 类型的 mixin 对象本身
472
+ */
473
+ export declare function targetMixin<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M>;
474
+
475
+ /**
476
+ * typeof 的返回类型
477
+ */
478
+ export declare type TypeOfReturnType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
479
+
480
+ /**
481
+ * 等待可异步的结果
482
+ *
483
+ * @remarks
484
+ * 当 asyncable 为同步值时,会同步调用 callback。
485
+ * 当 asyncable 为异步值时,会等待 asyncable 解决后再调用 callback。
486
+ *
487
+ * @param asyncable - 可异步的结果
488
+ * @param callback
489
+ * @returns
490
+ */
491
+ export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Return>;
492
+
493
+ /**
494
+ * waitAsyncable 的回调函数的类型
495
+ * @param result - 同步的结果
496
+ * @param rejected - 异步是否被拒绝
497
+ */
498
+ export declare type WaitAsyncableCallback<Result, Return> = (result: ResolveData<Result> | null | undefined, rejected: boolean) => Return;
499
+
500
+ /**
501
+ * waitAsyncable 的返回值的类型
502
+ */
503
+ export declare type WaitAsyncableReturn<Result> = Result extends Promise<any> ? Result : Promise<Result> | Result;
504
+
505
+ export { }