type-tls 2.7.0 → 3.0.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 (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +86 -86
  3. package/dist/async.d.ts +28 -0
  4. package/dist/base.d.ts +261 -0
  5. package/dist/buffer.d.ts +1 -0
  6. package/dist/function.d.ts +49 -0
  7. package/dist/index.d.ts +5 -630
  8. package/dist/member.d.ts +21 -0
  9. package/dist/tsdoc-metadata.json +1 -1
  10. package/dist/type-tls.d.ts +14 -317
  11. package/dist/type-tls.iife.js +1 -1
  12. package/dist/type-tls.js +108 -0
  13. package/dist/type-tls.umd.cjs +1 -0
  14. package/doc/api/type-tls.anyfunction.md +2 -2
  15. package/doc/api/type-tls.arrayitemtype.md +2 -2
  16. package/doc/api/type-tls.exacttype.md +3 -3
  17. package/doc/api/type-tls.exacttypename.md +3 -3
  18. package/doc/api/type-tls.getexacttypenameof.md +2 -2
  19. package/doc/api/type-tls.getexacttypeof.md +2 -2
  20. package/doc/api/type-tls.getnameoftype.md +2 -2
  21. package/doc/api/type-tls.gettypebyname.md +2 -2
  22. package/doc/api/type-tls.gettypenameof.md +2 -2
  23. package/doc/api/type-tls.gettypeof.md +2 -2
  24. package/doc/api/type-tls.isanonymousfunction.md +2 -2
  25. package/doc/api/type-tls.isarraylike.md +2 -2
  26. package/doc/api/type-tls.isarrowfunction.md +2 -2
  27. package/doc/api/type-tls.isasyncfunction.md +2 -2
  28. package/doc/api/type-tls.isasyncgeneratorfunction.md +2 -2
  29. package/doc/api/type-tls.isbasetype.md +2 -2
  30. package/doc/api/type-tls.isgeneratorfunction.md +2 -2
  31. package/doc/api/type-tls.isidentifier.md +2 -2
  32. package/doc/api/type-tls.isiterable.md +2 -2
  33. package/doc/api/type-tls.isiterator.md +2 -2
  34. package/doc/api/type-tls.isobject.md +2 -2
  35. package/doc/api/type-tls.keyofcontainsvalue.md +3 -3
  36. package/doc/api/type-tls.keyofnoncontainsvalue.md +3 -3
  37. package/doc/api/type-tls.keyofnonvalue.md +3 -3
  38. package/doc/api/type-tls.keyofvalue.md +3 -3
  39. package/doc/api/type-tls.loosetype.md +2 -2
  40. package/doc/api/type-tls.loosetypename.md +2 -2
  41. package/doc/api/type-tls.md +2 -39
  42. package/doc/api/type-tls.methodparams.md +3 -3
  43. package/doc/api/type-tls.methodreturntype.md +3 -3
  44. package/doc/api/type-tls.optional.md +2 -2
  45. package/doc/api/type-tls.optionalboolean.md +3 -3
  46. package/doc/api/type-tls.pickcontainsvalue.md +4 -4
  47. package/doc/api/type-tls.pickmethod.md +3 -3
  48. package/doc/api/type-tls.picknoncontainsvalue.md +4 -4
  49. package/doc/api/type-tls.picknonvalue.md +4 -4
  50. package/doc/api/type-tls.pickproperty.md +3 -3
  51. package/doc/api/type-tls.pickvalue.md +4 -4
  52. package/doc/api/type-tls.replace.md +2 -2
  53. package/doc/api/type-tls.replacenull.md +3 -3
  54. package/doc/api/type-tls.replaceundefined.md +3 -3
  55. package/doc/api/type-tls.replacevoid.md +3 -3
  56. package/doc/api/type-tls.resolvedata.md +2 -2
  57. package/doc/api/type-tls.twolayerpartial.md +20 -0
  58. package/doc/api/type-tls.typedarray.md +11 -0
  59. package/doc/api/type-tls.typeofreturntype.md +2 -2
  60. package/doc/api/type-tls.waitasyncable.md +2 -2
  61. package/doc/api/type-tls.waitasyncablecallback.md +3 -3
  62. package/doc/api/type-tls.waitasyncablereturn.md +2 -2
  63. package/doc//346/225/231/347/250/213.md +6 -6
  64. package/package.json +20 -11
  65. package/dist/type-tls.mjs +0 -214
  66. package/dist/type-tls.umd.js +0 -1
  67. package/doc/api/type-tls.axis.getcrossaxiss.md +0 -32
  68. package/doc/api/type-tls.axis.md +0 -22
  69. package/doc/api/type-tls.axis.toindex.md +0 -25
  70. package/doc/api/type-tls.axis.tokey.md +0 -25
  71. package/doc/api/type-tls.axis4.getcrossaxiss.md +0 -32
  72. package/doc/api/type-tls.axis4.md +0 -22
  73. package/doc/api/type-tls.axis4.toindex.md +0 -25
  74. package/doc/api/type-tls.axis4.tokey.md +0 -25
  75. package/doc/api/type-tls.axis4name.md +0 -13
  76. package/doc/api/type-tls.axisname.md +0 -13
  77. package/doc/api/type-tls.classtype._new_.md +0 -22
  78. package/doc/api/type-tls.classtype.md +0 -20
  79. package/doc/api/type-tls.createdefinemixin.md +0 -23
  80. package/doc/api/type-tls.createextendtarget.md +0 -30
  81. package/doc/api/type-tls.createmixintarget.md +0 -30
  82. package/doc/api/type-tls.createtargetextend.md +0 -30
  83. package/doc/api/type-tls.createtargetmixin.md +0 -30
  84. package/doc/api/type-tls.defineextend.md +0 -35
  85. package/doc/api/type-tls.definemixin.md +0 -31
  86. package/doc/api/type-tls.extendtarget.md +0 -31
  87. package/doc/api/type-tls.ivector.md +0 -15
  88. package/doc/api/type-tls.ivector2.md +0 -21
  89. package/doc/api/type-tls.ivector2.x.md +0 -11
  90. package/doc/api/type-tls.ivector2.y.md +0 -11
  91. package/doc/api/type-tls.ivector3.md +0 -21
  92. package/doc/api/type-tls.ivector3.z.md +0 -11
  93. package/doc/api/type-tls.ivector4.md +0 -21
  94. package/doc/api/type-tls.ivector4.w.md +0 -11
  95. package/doc/api/type-tls.mixin_4.md +0 -33
  96. package/doc/api/type-tls.mixintarget.md +0 -31
  97. package/doc/api/type-tls.privatememberofextend._constructor.md +0 -22
  98. package/doc/api/type-tls.privatememberofextend.md +0 -20
  99. package/doc/api/type-tls.targetextend.md +0 -31
  100. package/doc/api/type-tls.targetmixin.md +0 -31
package/dist/index.d.ts CHANGED
@@ -1,630 +1,5 @@
1
- /**
2
- * 判断 code 是否是有校的 js 标识符
3
- * @param code - 标识符的字符串
4
- */
5
- export declare function isIdentifier(code: string): boolean;
6
- /**
7
- * 判断函数是否是箭头函数
8
- * @param fun - 被判断的函数
9
- */
10
- export declare function isArrowFunction(fun: Function): boolean;
11
- /**
12
- * 判断函数是否是 async 异步函数
13
- * @remarks
14
- * 异步函数 不包含 异步生成器函数 AsyncGeneratorFunction
15
- * @param fun - 被判断的函数
16
- */
17
- export declare function isAsyncFunction(fun: Function): boolean;
18
- /**
19
- * 判断函数是否是生成器函数
20
- *
21
- * @remarks
22
- * 生成器函数 不包含 异步生成器函数 AsyncGeneratorFunction
23
- * @param fun - 被判断的函数
24
- */
25
- export declare function isGeneratorFunction(fun: Function): boolean;
26
- /**
27
- * 判断函数是否是异步生成器函数
28
- * @param fun - 被判断的函数
29
- */
30
- export declare function isAsyncGeneratorFunction(fun: Function): boolean;
31
- /**
32
- * 判断是否是匿名函数
33
- *
34
- * @remarks
35
- * 判断函数在被定义时是否是通过匿名函数来定义的。
36
- * 匿名函数是指声明函数时没有写名字的函数。
37
- * 注意:即使是匿名函数,函数对象上的 name 属性也可能是有值的,因为 js解析器 会自动将 函数表达式函数变量的名字作为匿名函数的名字,如下:
38
- * ```ts
39
- * var funName = function(){};
40
- * ```
41
- * 其中的匿名函数对象的 name 属性的值会是 `funName`
42
- *
43
- * 如果 函数对象上的 name 属性的值为 `""`,函数一定是匿名函数。
44
- */
45
- export declare function isAnonymousFunction(fun: Function): boolean;
46
- /**
47
- * 表示任意的函数类型
48
- */
49
- export declare type AnyFunction = (...args: any) => any;
50
- /**
51
- * 判断目标是否是对象类型
52
- *
53
- * @remarks
54
- * 仅通过 target instanceof Object 判断是不行的,因为 对于 Object.create(null) 创建的对象 通过 ` Object.create(null) instanceof Object ` 来判断 返回的是 false
55
- * 即:通过 Object.create(null) 创建的对象是不被 instanceof 认为是继续于 Object 的
56
- *
57
- * typeof null 也返回 "object"
58
- *
59
- * @param target : any 目标对象
60
- */
61
- export declare function isObject(target: any): boolean;
62
- /**
63
- * typeof 的返回类型
64
- */
65
- export declare type TypeOfReturnType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
66
- /**
67
- * 宽松的类型
68
- */
69
- export declare type LooseType = undefined | null | Function | "object";
70
- /**
71
- * 宽松类型的字符串表示
72
- */
73
- export declare type LooseTypeName = "undefined" | "null" | "Function" | "object" | string;
74
- /**
75
- * 精确类型
76
- *
77
- * @remarks
78
- * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
79
- * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
80
- * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
81
- * 但,对于 undefined 和 null 会返回其自身值(即 undefined 和 null)作为类型值
82
- *
83
- * 各种类型的值 与 该方法的返回值 的映射如下:
84
- * ```
85
- * undefined :undefined
86
- * null : null
87
- * string : "string"
88
- * number : "number"
89
- * bigint : "bigint"
90
- * boolean : "boolean"
91
- * symbol : "symbol"
92
- * function : Function
93
- * 没有原型的对象(如:通过 `Object.create(null)` 创建的对象) : "object"
94
- * 其它任何类型的实例 : 返回该实例的构造函数
95
- * ```
96
- */
97
- export declare type ExactType = LooseType | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
98
- /**
99
- * 精确类型的字符串表示
100
- *
101
- * @remarks
102
- * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
103
- * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
104
- * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
105
- * 但,对于 null 会返回 "null"
106
- *
107
- * 各种类型的值 与 该方法的返回值 的映射如下:
108
- * ```
109
- * undefined :"undefined"
110
- * null : "null"
111
- * function : "Function"
112
- * string : "string"
113
- * number : "number"
114
- * bigint : "bigint"
115
- * boolean : "boolean"
116
- * symbol : "symbol"
117
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
118
- * 其它任何类型的实例 : 返回该实例的构造函数的名字
119
- * ```
120
- */
121
- export declare type ExactTypeName = LooseTypeName | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
122
- /**
123
- * 获取 inst 的宽松类型
124
- *
125
- * @remarks
126
- * 注意:
127
- * 本方法返回的结果如下:
128
- * ```
129
- * undefined :undefined
130
- * null : null
131
- * function : Function
132
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
133
- * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数
134
- * ```
135
- *
136
- *
137
- * @param inst
138
- * @returns inst 的类型
139
- */
140
- export declare function getTypeOf(inst: any): LooseType;
141
- /**
142
- * 获取 类型的字符串表示
143
- *
144
- * @param t - 一个 ExactType 类型的值
145
- * @return t 的字符串表示的类型
146
- */
147
- export declare function getNameOfType(t: ExactType): ExactTypeName;
148
- /**
149
- * 根据类型的名字获取其对应的类
150
- * @param typeName - 类型的名字
151
- */
152
- export declare function getTypeByName(typeName: string): Function | undefined;
153
- /**
154
- * 获取 inst 的类型字符串
155
- *
156
- * @remarks
157
- * 注意:
158
- * 本方法返回的结果如下:
159
- * undefined :"undefined"
160
- * null : "null"
161
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
162
- * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数 的函数名字
163
- *
164
- * @param inst
165
- * @returns inst 的类型字符串
166
- */
167
- export declare function getTypeNameOf(inst: any): LooseTypeName;
168
- /**
169
- * 获取 inst 的精确类型
170
- * @param inst
171
- * @returns inst 的类型
172
- */
173
- export declare function getExactTypeOf(inst: any): ExactType;
174
- /**
175
- * 获取 inst 的精确类型的字符串表示
176
- * @param inst
177
- * @returns inst 的类型字符串
178
- */
179
- export declare function getExactTypeNameOf(inst: any): ExactTypeName;
180
- /**
181
- * 判断 data 是否是 基本类型
182
- * @remarks
183
- * 基本类型 是指 那些不是 对象类型的类型,即,除了 object 和 function 类型以外,其它的都是基本类型,null 也算怎是 基本类型
184
- * @param data - 任意类型的值
185
- */
186
- export declare function isBaseType(data: any): boolean;
187
- /**
188
- * 判断 target 是否为 类数组对象
189
- * @param target - 目标
190
- * @returns
191
- */
192
- export declare function isArrayLike(target: any): boolean;
193
- /**
194
- * 判断 目标 是否是可迭代的对象,即 实现了 可迭代协议
195
- * @param target - 目标
196
- */
197
- export declare function isIterable(target: any): boolean;
198
- /**
199
- * 判断 目标 是否是迭代器,即 实现了 迭代器协议
200
- * @param target - 目标
201
- */
202
- export declare function isIterator(target: any): boolean;
203
- /**
204
- * 将某个类型变为可选的类型
205
- */
206
- export declare type Optional<T> = T | null | undefined;
207
- /**
208
- * 可选的布尔类型
209
- */
210
- export declare type OptionalBoolean = Optional<boolean>;
211
- /**
212
- * 获取值类型为指定类型的所有 key
213
- *
214
- * @typeParam Target - 目标对象
215
- * @typeParam Value - 要获取的key的对应值的类型
216
- */
217
- export declare type KeyOfValue<Target, Value> = {
218
- [K in keyof Target]: Target[K] extends Value ? K : never;
219
- }[keyof Target];
220
- /**
221
- * 获取值类型不是指定类型的所有 key
222
- *
223
- * @typeParam Target - 目标对象
224
- * @typeParam Value - 被排除的值的类型
225
- */
226
- export declare type KeyOfNonValue<Target, Value> = {
227
- [K in keyof Target]: Target[K] extends Value ? never : K;
228
- }[keyof Target];
229
- /**
230
- * 获取值类型包含指定类型的所有 key
231
- *
232
- * @typeParam Target - 目标对象
233
- * @typeParam Value - 要获取的key的对应值应包含的类型
234
- */
235
- export declare type KeyOfContainsValue<Target, Value> = {
236
- [K in keyof Target]: Value extends Target[K] ? K : never;
237
- }[keyof Target];
238
- /**
239
- * 获取值类型不应包含指定类型的所有 key
240
- *
241
- * @typeParam Target - 目标对象
242
- * @typeParam Value - 不应包含的值的类型
243
- */
244
- export declare type KeyOfNonContainsValue<Target, Value> = {
245
- [K in keyof Target]: Value extends Target[K] ? never : K;
246
- }[keyof Target];
247
- /**
248
- * 从 T 中挑选出那些成员值为 Value 的类型的成员
249
- */
250
- export declare type PickValue<Target, Value> = {
251
- [P in KeyOfValue<Target, Value>]: Target[P];
252
- };
253
- /**
254
- * 从 Target 中挑选出那些成员值不是 Value 的类型的成员
255
- */
256
- export declare type PickNonValue<Target, Value> = {
257
- [P in KeyOfNonValue<Target, Value>]: Target[P];
258
- };
259
- /**
260
- * 从 Target 中挑选出那些成员值的类型包含 Value 类型的成员
261
- */
262
- export declare type PickContainsValue<Target, Value> = {
263
- [P in KeyOfContainsValue<Target, Value>]: Target[P];
264
- };
265
- /**
266
- * 从 Target 中挑选出那些成员值的类型不包含 Value 类型的成员
267
- */
268
- export declare type PickNonContainsValue<Target, Value> = {
269
- [P in KeyOfNonContainsValue<Target, Value>]: Target[P];
270
- };
271
- /**
272
- * 从 Target 中挑选出属性
273
- */
274
- export declare type PickProperty<Target> = PickNonValue<Target, AnyFunction>;
275
- /**
276
- * 从 Target 中挑选出方法
277
- */
278
- export declare type PickMethod<Target> = PickValue<Target, AnyFunction>;
279
- /**
280
- * 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType
281
- */
282
- export declare type Replace<SourType, MatchType, NewType> = SourType extends MatchType ? NewType : SourType;
283
- /**
284
- * 可将源类型 SourType 中的 undefined 替换为 新的类型 NewType
285
- */
286
- export declare type ReplaceUndefined<SourType, NewType> = Replace<SourType, undefined, NewType>;
287
- /**
288
- * 可将源类型 SourType 中的 null 替换为 新的类型 NewType
289
- */
290
- export declare type ReplaceNull<SourType, NewType> = Replace<SourType, null, NewType>;
291
- /**
292
- * 可将源类型 SourType 中的代表空的类型 void | undefined | null 替换为 新的类型 NewType
293
- */
294
- export declare type ReplaceVoid<SourType, NewType> = Replace<SourType, void | undefined | null, NewType>;
295
- /**
296
- * 混合
297
- * @internal
298
- */
299
- export declare function mixin<T, S>(target: T, source: S): T & S;
300
- /**
301
- * 混合
302
- * @internal
303
- */
304
- export declare function mixin<T, S1, S2>(target: T, source1: S1, source2: S2): T & S1 & S2;
305
- /**
306
- * 混合
307
- * @internal
308
- */
309
- export declare function mixin<T, S1, S2, S3>(target: T, source1: S1, source2: S2, source3: S3): T & S1 & S2 & S3;
310
- /**
311
- * 混合
312
- * @internal
313
- */
314
- export declare function mixin<T, S1, S2, S3, S4>(target: T, source1: S1, source2: S2, source3: S3, source4: S3): T & S1 & S2 & S3 & S4;
315
- /**
316
- * 混合
317
- *
318
- * @remarks
319
- * 将 source 的所有成员混入 target 对象中。
320
- *
321
- * 与 `Object.assign()` 的功能类似,不同的是 `mixin()` 会在 target 对象中 保持 source 对象属性的 PropertyDescriptors
322
- *
323
- * @param target - 目标对象,所有 源对象 的属性都要被混入进到 目标对象中
324
- * @param sources - 源对象,所有 源对象 的属性都要被混入进到 目标对象中
325
- * @returns 混入后的 target
326
- */
327
- export declare function mixin(target: any, ...sources: any[]): any;
328
- /**
329
- * 定义混合的类型便利函数
330
- *
331
- * @remarks
332
- * 它会更改 mixin 中方法的this指向为 target & mixin,不会真的执行混合操作
333
- *
334
- * @param target - 混合的目标,用作 this 的类型
335
- * @param mixin - 混合对象,会自动更改其this的类型
336
- * @returns 返回注入了 this 类型的 mixin 对象本身
337
- */
338
- export declare function defineMixin<T, M>(target: T, mixin: M & ThisType<T & M>): M & ThisType<T & M>;
339
- /**
340
- * 创建定义混合的类型便利函数
341
- *
342
- * @remarks
343
- * 它返回的便利函数的功能与 {@link defineMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
344
- *
345
- * @returns 可以用于 定义混合的 类型便利函数
346
- */
347
- export declare function createDefineMixin<T>(): <M>(target: T, mixin: M & ThisType<T & M>) => M & ThisType<T & M>;
348
- /**
349
- * 混合目标
350
- *
351
- * @remarks
352
- * 与 {@link defineMixin} 的区别是:`targetMixin` 会执行对 target 的混合操作,而 {@link defineMixin} 不会
353
- *
354
- *
355
- * @param target - 混合的目标,用作 this 的类型
356
- * @param m - 混合对象,会自动更改其this的类型
357
- * @returns 返回注入了 this 类型的 mixin 对象本身
358
- */
359
- export declare function targetMixin<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M>;
360
- /**
361
- * 创建用于混合目标的便捷函数
362
- *
363
- * @remarks
364
- * 它返回的便利函数的功能与 {@link targetMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
365
- *
366
- * @param target - 混合的目标,用作 this 的类型
367
- * @returns 可以用于 混合目标 的便利函数
368
- */
369
- export declare function createTargetMixin<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M>;
370
- /**
371
- * 混合目标
372
- *
373
- * @remarks
374
- * 会执行对 CEarth 类的扩展操作。
375
- * 与 {@link targetMixin} 的区别仅仅是返回类型不一样。
376
- *
377
- * @param target - 混合的目标,用作 this 的类型
378
- * @param m - 混合对象,会自动更改其this的类型
379
- * @returns 返回混合后的 target 对象
380
- */
381
- export declare function mixinTarget<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M> & T;
382
- /**
383
- * 创建用于混合目标工具函数
384
- *
385
- * @remarks
386
- * 它返回的便利函数的功能与 {@link mixinTarget} 的功能一样,唯一区别是不再需要接收 target 参数了
387
- *
388
- * @returns 可以用于 混合目标 的便利函数
389
- */
390
- export declare function createMixinTarget<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M> & T;
391
- /**
392
- * 类的类型、构造函数的类型
393
- *
394
- * @typeParam Arg - 构建函数的参数类型
395
- * @typeParam Instance - 构建函数的返回的实例类型
396
- */
397
- export interface ClassType<Arg extends any[] = any[], Instance = any> {
398
- new (...args: Arg): Instance;
399
- }
400
- /**
401
- * 用于定义扩展选项中的私有成员
402
- */
403
- export interface PrivateMemberOfExtend<TargetType extends new (...args: any) => any> {
404
- /**
405
- * 扩展类中用于定义在创建实例时的初始化的方法
406
- * @remarks
407
- * 该方法会在创建实例时自动执行,并将构建函数接收到的参数透传给方方法。
408
- *
409
- * 注意:
410
- * _constructor 会被保存在 目标类中的 _constructors 属性中,它是一个数组。
411
- *
412
- * 目标类 需要在自己的构建函数中逐个调用 cla._constructors 中的函数
413
- *
414
- * @param args
415
- */
416
- _constructor?: (...args: (TargetType extends new (...args: infer A) => any ? A : never)) => void;
417
- }
418
- /**
419
- * 定义扩展的类型便利函数
420
- *
421
- * @remarks
422
- * 它会更改 ext 中方法的this指向为 cla & ext,不会真的执行扩展操作。
423
- *
424
- * 其中 ext._constructor 会被保存在 cla._constructors 属性中,它是一个数组。
425
- *
426
- * cla 需要在自己的构建函数中逐个调用 cla._constructors 中的函数
427
- *
428
- * @param cla - 扩展的目标,用作 this 的类型
429
- * @param ext - 描述扩展内容的对象,会自动更改其this的类型
430
- * @returns 返回注入了 this 类型的 ext 对象本身
431
- */
432
- export declare function defineExtend<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): E & ThisType<C & E>;
433
- /**
434
- * 扩展目标
435
- *
436
- * @remarks
437
- * 与 {@link defineExtend} 的区别是:`targetExtend` 会执行对 cla 的扩展操作,而 {@link defineExtend} 不会
438
- *
439
- *
440
- * @param cla - 扩展的目标,也用作 this 的类型
441
- * @param ext - 扩展描述对象,会自动更改其this的类型
442
- * @returns 返回注入了 this 类型的 ext 对象本身
443
- */
444
- export declare function targetExtend<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): E & ThisType<InstanceType<C> & E>;
445
- /**
446
- * 创建用于扩展目标的便捷函数
447
- *
448
- * @remarks
449
- * 它返回的便利函数的功能与 {@link targetExtend} 的功能一样,唯一区别是不再需要接收 cla 参数了
450
- *
451
- * @param cla - 扩展的目标,也用作 this 的类型
452
- * @returns 可以用于 扩展目标 的便利函数
453
- */
454
- export declare function createTargetExtend<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>) => E & ThisType<C & E>;
455
- /**
456
- * 扩展目标
457
- *
458
- * @remarks
459
- * 会执行对 CEarth 类的扩展操作。
460
- * 与 {@link targetExtend} 的区别仅仅是返回类型不一样。
461
- *
462
- * @param cla - 扩展的目标,也用作 this 的类型
463
- * @param ext - 扩展对象,会自动更改其this的类型
464
- * @returns 返回扩展后的 cla 对象
465
- */
466
- 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>>;
467
- /**
468
- * 创建用于扩展目标工具函数
469
- *
470
- * @remarks
471
- * 它返回的便利函数的功能与 {@link extendTarget} 的功能一样,唯一区别是不再需要接收 cla 参数了
472
- *
473
- * @param cla - 扩展的目标,也用作 this 的类型
474
- * @returns 可以用于 扩展目标 的便利函数
475
- */
476
- 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>>;
477
- /**
478
- * 获取对象的方法的某个参数的类型
479
- *
480
- * @typeParam Obj - 对象
481
- * @typeParam Method - 对象方法的名字
482
- * @typeParam ParamIndex - 参数的索引个数
483
- */
484
- export declare type MethodParams<Obj, Method extends keyof Obj, ParamIndex extends number> = Obj[Method] extends AnyFunction ? Parameters<Obj[Method]>[ParamIndex] : never;
485
- /**
486
- * 获取对象的方法的返回的类型
487
- *
488
- * @typeParam Obj - 对象
489
- * @typeParam Method - 对象方法的名字
490
- */
491
- export declare type MethodReturnType<Obj, Method extends keyof Obj> = Obj[Method] extends AnyFunction ? ReturnType<Obj[Method]> : never;
492
- /**
493
- * 获取数组元素的类型
494
- * @typeParam Arr 数组
495
- */
496
- export declare type ArrayItemType<Arr> = Arr extends (infer Item)[] ? Item : never;
497
- /**
498
- * 获取 Promise 解决的类型的值
499
- * @remarks
500
- * 对于非 Promise 类型的值,返回原类型本身
501
- */
502
- export declare type ResolveData<P> = P extends Promise<infer D> ? D : P;
503
- /**
504
- * waitAsyncable 的返回值的类型
505
- */
506
- export declare type WaitAsyncableReturn<Result, Return> = Return extends Promise<any> ? Return : (Result extends Promise<any> ? Promise<Return> : Return);
507
- /**
508
- * waitAsyncable 的回调函数的类型
509
- * @param result - 同步的结果
510
- * @param rejected - 异步是否被拒绝
511
- */
512
- export declare type WaitAsyncableCallback<Result, Return> = (result: ResolveData<Result> | undefined, rejected: boolean, error: any) => Return;
513
- /**
514
- * 等待可异步的结果
515
- *
516
- * @remarks
517
- * 当 asyncable 为同步值时,会同步调用 callback。
518
- * 当 asyncable 为异步值时,会等待 asyncable 解决后再调用 callback。
519
- *
520
- * @param asyncable - 可异步的结果
521
- * @param callback
522
- * @returns
523
- */
524
- export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Result, Return>;
525
- /**
526
- * 二维向量
527
- */
528
- export interface IVector2 {
529
- x: number;
530
- y: number;
531
- }
532
- /**
533
- * 三维向量
534
- */
535
- export interface IVector3 extends IVector2 {
536
- z: number;
537
- }
538
- /**
539
- * 四维向量
540
- */
541
- export interface IVector4 extends IVector3 {
542
- w: number;
543
- }
544
- /**
545
- * 向量
546
- */
547
- export declare type IVector = IVector2 | IVector3 | IVector4;
548
- /**
549
- * 轴名
550
- */
551
- export declare type AxisName = "x" | "y" | "z";
552
- /**
553
- * 轴
554
- */
555
- export declare enum Axis {
556
- x = 0,
557
- y = 1,
558
- z = 2
559
- }
560
- /**
561
- * 轴的方法
562
- */
563
- export declare namespace Axis {
564
- /**
565
- * 将轴索引转为轴名字
566
- * @param index - 索引
567
- * @returns
568
- */
569
- function toKey(index: Axis): AxisName;
570
- /**
571
- * 将轴名字转为轴索引
572
- * @param name
573
- * @returns
574
- */
575
- function toIndex(name: AxisName): Axis;
576
- /**
577
- * 获取剩余的另外两个轴
578
- * @remarks
579
- * 获取除 axis 之外的另外两个轴,且这两轴的顺序符合叉乘得 axis 轴的顺序
580
- * @param axis
581
- * @returns
582
- */
583
- function getCrossAxiss(axis: Axis): [
584
- Axis,
585
- Axis
586
- ];
587
- }
588
- /**
589
- * 四维轴的名字
590
- */
591
- export declare type Axis4Name = "x" | "y" | "z";
592
- /**
593
- * 四维轴
594
- */
595
- export declare enum Axis4 {
596
- x = 0,
597
- y = 1,
598
- z = 2,
599
- w = 3
600
- }
601
- /**
602
- * 四维轴的方法
603
- */
604
- export declare namespace Axis4 {
605
- /**
606
- * 将轴索引转为轴名字
607
- * @param index - 索引
608
- * @returns
609
- */
610
- function toKey(index: Axis4): Axis4Name;
611
- /**
612
- * 将轴名字转为轴索引
613
- * @param name
614
- * @returns
615
- */
616
- function toIndex(name: Axis4Name): Axis4;
617
- /**
618
- * 获取剩余的另外两个轴
619
- * @remarks
620
- * 获取除 axis 之外的另外两个轴,且这两轴的顺序符合叉乘得 axis 轴的顺序
621
- * @param axis
622
- * @returns
623
- */
624
- function getCrossAxiss(axis: Axis4): [
625
- Axis4,
626
- Axis4
627
- ];
628
- }
629
-
630
- export {};
1
+ export * from './base';
2
+ export * from './function';
3
+ export * from './member';
4
+ export * from './async';
5
+ export * from './buffer';
@@ -0,0 +1,21 @@
1
+ import { AnyFunction } from "./function";
2
+ /**
3
+ * 获取对象的方法的某个参数的类型
4
+ *
5
+ * @typeParam Obj - 对象
6
+ * @typeParam Method - 对象方法的名字
7
+ * @typeParam ParamIndex - 参数的索引个数
8
+ */
9
+ export type MethodParams<Obj, Method extends keyof Obj, ParamIndex extends number> = Obj[Method] extends AnyFunction ? Parameters<Obj[Method]>[ParamIndex] : never;
10
+ /**
11
+ * 获取对象的方法的返回的类型
12
+ *
13
+ * @typeParam Obj - 对象
14
+ * @typeParam Method - 对象方法的名字
15
+ */
16
+ export type MethodReturnType<Obj, Method extends keyof Obj> = Obj[Method] extends AnyFunction ? ReturnType<Obj[Method]> : never;
17
+ /**
18
+ * 获取数组元素的类型
19
+ * @typeParam Arr 数组
20
+ */
21
+ export type ArrayItemType<Arr> = Arr extends (infer Item)[] ? Item : never;
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.29.5"
8
+ "packageVersion": "7.39.1"
9
9
  }
10
10
  ]
11
11
  }