type-tls 2.6.0 → 2.7.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.
- package/dist/index.d.ts +65 -64
- package/dist/type-tls.d.ts +22 -20
- package/doc/api/index.md +1 -1
- package/doc/api/type-tls.md +6 -10
- package/doc/api/type-tls.pickcontainsvalue.md +3 -3
- package/doc/api/type-tls.pickmethod.md +15 -0
- package/doc/api/type-tls.picknoncontainsvalue.md +3 -3
- package/doc/api/type-tls.picknonvalue.md +3 -3
- package/doc/api/type-tls.pickproperty.md +15 -0
- package/doc/api/type-tls.pickvalue.md +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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 异步函数
|
|
3
13
|
* @remarks
|
|
4
|
-
*
|
|
14
|
+
* 异步函数 不包含 异步生成器函数 AsyncGeneratorFunction
|
|
15
|
+
* @param fun - 被判断的函数
|
|
16
|
+
*/
|
|
17
|
+
export declare function isAsyncFunction(fun: Function): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 判断函数是否是生成器函数
|
|
5
20
|
*
|
|
6
|
-
* @
|
|
21
|
+
* @remarks
|
|
22
|
+
* 生成器函数 不包含 异步生成器函数 AsyncGeneratorFunction
|
|
23
|
+
* @param fun - 被判断的函数
|
|
7
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;
|
|
8
50
|
/**
|
|
9
51
|
* 判断目标是否是对象类型
|
|
10
52
|
*
|
|
@@ -203,29 +245,37 @@ export declare type KeyOfNonContainsValue<Target, Value> = {
|
|
|
203
245
|
[K in keyof Target]: Value extends Target[K] ? never : K;
|
|
204
246
|
}[keyof Target];
|
|
205
247
|
/**
|
|
206
|
-
* 从 T 中挑选出那些成员值为
|
|
248
|
+
* 从 T 中挑选出那些成员值为 Value 的类型的成员
|
|
207
249
|
*/
|
|
208
|
-
export declare type PickValue<
|
|
209
|
-
[P in KeyOfValue<
|
|
250
|
+
export declare type PickValue<Target, Value> = {
|
|
251
|
+
[P in KeyOfValue<Target, Value>]: Target[P];
|
|
210
252
|
};
|
|
211
253
|
/**
|
|
212
|
-
* 从
|
|
254
|
+
* 从 Target 中挑选出那些成员值不是 Value 的类型的成员
|
|
213
255
|
*/
|
|
214
|
-
export declare type PickNonValue<
|
|
215
|
-
[P in KeyOfNonValue<
|
|
256
|
+
export declare type PickNonValue<Target, Value> = {
|
|
257
|
+
[P in KeyOfNonValue<Target, Value>]: Target[P];
|
|
216
258
|
};
|
|
217
259
|
/**
|
|
218
|
-
* 从
|
|
260
|
+
* 从 Target 中挑选出那些成员值的类型包含 Value 类型的成员
|
|
219
261
|
*/
|
|
220
|
-
export declare type PickContainsValue<
|
|
221
|
-
[P in KeyOfContainsValue<
|
|
262
|
+
export declare type PickContainsValue<Target, Value> = {
|
|
263
|
+
[P in KeyOfContainsValue<Target, Value>]: Target[P];
|
|
222
264
|
};
|
|
223
265
|
/**
|
|
224
|
-
* 从
|
|
266
|
+
* 从 Target 中挑选出那些成员值的类型不包含 Value 类型的成员
|
|
225
267
|
*/
|
|
226
|
-
export declare type PickNonContainsValue<
|
|
227
|
-
[P in KeyOfNonContainsValue<
|
|
268
|
+
export declare type PickNonContainsValue<Target, Value> = {
|
|
269
|
+
[P in KeyOfNonContainsValue<Target, Value>]: Target[P];
|
|
228
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>;
|
|
229
279
|
/**
|
|
230
280
|
* 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType
|
|
231
281
|
*/
|
|
@@ -424,55 +474,6 @@ export declare function extendTarget<C extends ClassType, E>(cla: C, ext: E & Th
|
|
|
424
474
|
* @returns 可以用于 扩展目标 的便利函数
|
|
425
475
|
*/
|
|
426
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>>;
|
|
427
|
-
/**
|
|
428
|
-
* 判断 code 是否是有校的 js 标识符
|
|
429
|
-
* @param code - 标识符的字符串
|
|
430
|
-
*/
|
|
431
|
-
export declare function isIdentifier(code: string): boolean;
|
|
432
|
-
/**
|
|
433
|
-
* 判断函数是否是箭头函数
|
|
434
|
-
* @param fun - 被判断的函数
|
|
435
|
-
*/
|
|
436
|
-
export declare function isArrowFunction(fun: Function): boolean;
|
|
437
|
-
/**
|
|
438
|
-
* 判断函数是否是 async 异步函数
|
|
439
|
-
* @remarks
|
|
440
|
-
* 异步函数 不包含 异步生成器函数 AsyncGeneratorFunction
|
|
441
|
-
* @param fun - 被判断的函数
|
|
442
|
-
*/
|
|
443
|
-
export declare function isAsyncFunction(fun: Function): boolean;
|
|
444
|
-
/**
|
|
445
|
-
* 判断函数是否是生成器函数
|
|
446
|
-
*
|
|
447
|
-
* @remarks
|
|
448
|
-
* 生成器函数 不包含 异步生成器函数 AsyncGeneratorFunction
|
|
449
|
-
* @param fun - 被判断的函数
|
|
450
|
-
*/
|
|
451
|
-
export declare function isGeneratorFunction(fun: Function): boolean;
|
|
452
|
-
/**
|
|
453
|
-
* 判断函数是否是异步生成器函数
|
|
454
|
-
* @param fun - 被判断的函数
|
|
455
|
-
*/
|
|
456
|
-
export declare function isAsyncGeneratorFunction(fun: Function): boolean;
|
|
457
|
-
/**
|
|
458
|
-
* 判断是否是匿名函数
|
|
459
|
-
*
|
|
460
|
-
* @remarks
|
|
461
|
-
* 判断函数在被定义时是否是通过匿名函数来定义的。
|
|
462
|
-
* 匿名函数是指声明函数时没有写名字的函数。
|
|
463
|
-
* 注意:即使是匿名函数,函数对象上的 name 属性也可能是有值的,因为 js解析器 会自动将 函数表达式函数变量的名字作为匿名函数的名字,如下:
|
|
464
|
-
* ```ts
|
|
465
|
-
* var funName = function(){};
|
|
466
|
-
* ```
|
|
467
|
-
* 其中的匿名函数对象的 name 属性的值会是 `funName`
|
|
468
|
-
*
|
|
469
|
-
* 如果 函数对象上的 name 属性的值为 `""`,函数一定是匿名函数。
|
|
470
|
-
*/
|
|
471
|
-
export declare function isAnonymousFunction(fun: Function): boolean;
|
|
472
|
-
/**
|
|
473
|
-
* 表示任意的函数类型
|
|
474
|
-
*/
|
|
475
|
-
export declare type AnyFunction = (...args: any) => any;
|
|
476
477
|
/**
|
|
477
478
|
* 获取对象的方法的某个参数的类型
|
|
478
479
|
*
|
package/dist/type-tls.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 处理类型相关的工具
|
|
3
|
-
* @remarks
|
|
4
|
-
* type-tls 封装了与类型相关的工具,比如获取数据的类型 或 类型名字、判断数据的类型 等
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
/**
|
|
10
2
|
* 表示任意的函数类型
|
|
11
3
|
*/
|
|
@@ -569,31 +561,41 @@ export declare type Optional<T> = T | null | undefined;
|
|
|
569
561
|
export declare type OptionalBoolean = Optional<boolean>;
|
|
570
562
|
|
|
571
563
|
/**
|
|
572
|
-
* 从
|
|
564
|
+
* 从 Target 中挑选出那些成员值的类型包含 Value 类型的成员
|
|
573
565
|
*/
|
|
574
|
-
export declare type PickContainsValue<
|
|
575
|
-
[P in KeyOfContainsValue<
|
|
566
|
+
export declare type PickContainsValue<Target, Value> = {
|
|
567
|
+
[P in KeyOfContainsValue<Target, Value>]: Target[P];
|
|
576
568
|
};
|
|
577
569
|
|
|
578
570
|
/**
|
|
579
|
-
* 从
|
|
571
|
+
* 从 Target 中挑选出方法
|
|
580
572
|
*/
|
|
581
|
-
export declare type
|
|
582
|
-
|
|
573
|
+
export declare type PickMethod<Target> = PickValue<Target, AnyFunction>;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* 从 Target 中挑选出那些成员值的类型不包含 Value 类型的成员
|
|
577
|
+
*/
|
|
578
|
+
export declare type PickNonContainsValue<Target, Value> = {
|
|
579
|
+
[P in KeyOfNonContainsValue<Target, Value>]: Target[P];
|
|
583
580
|
};
|
|
584
581
|
|
|
585
582
|
/**
|
|
586
|
-
* 从
|
|
583
|
+
* 从 Target 中挑选出那些成员值不是 Value 的类型的成员
|
|
587
584
|
*/
|
|
588
|
-
export declare type PickNonValue<
|
|
589
|
-
[P in KeyOfNonValue<
|
|
585
|
+
export declare type PickNonValue<Target, Value> = {
|
|
586
|
+
[P in KeyOfNonValue<Target, Value>]: Target[P];
|
|
590
587
|
};
|
|
591
588
|
|
|
592
589
|
/**
|
|
593
|
-
* 从
|
|
590
|
+
* 从 Target 中挑选出属性
|
|
591
|
+
*/
|
|
592
|
+
export declare type PickProperty<Target> = PickNonValue<Target, AnyFunction>;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* 从 T 中挑选出那些成员值为 Value 的类型的成员
|
|
594
596
|
*/
|
|
595
|
-
export declare type PickValue<
|
|
596
|
-
[P in KeyOfValue<
|
|
597
|
+
export declare type PickValue<Target, Value> = {
|
|
598
|
+
[P in KeyOfValue<Target, Value>]: Target[P];
|
|
597
599
|
};
|
|
598
600
|
|
|
599
601
|
/**
|
package/doc/api/index.md
CHANGED
package/doc/api/type-tls.md
CHANGED
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
## type-tls package
|
|
6
6
|
|
|
7
|
-
处理类型相关的工具
|
|
8
|
-
|
|
9
|
-
## Remarks
|
|
10
|
-
|
|
11
|
-
type-tls 封装了与类型相关的工具,比如获取数据的类型 或 类型名字、判断数据的类型 等
|
|
12
|
-
|
|
13
7
|
## Enumerations
|
|
14
8
|
|
|
15
9
|
| Enumeration | Description |
|
|
@@ -90,10 +84,12 @@ type-tls 封装了与类型相关的工具,比如获取数据的类型 或 类
|
|
|
90
84
|
| [MethodReturnType](./type-tls.methodreturntype.md) | 获取对象的方法的返回的类型 |
|
|
91
85
|
| [Optional](./type-tls.optional.md) | 将某个类型变为可选的类型 |
|
|
92
86
|
| [OptionalBoolean](./type-tls.optionalboolean.md) | 可选的布尔类型 |
|
|
93
|
-
| [PickContainsValue](./type-tls.pickcontainsvalue.md) | 从
|
|
94
|
-
| [
|
|
95
|
-
| [
|
|
96
|
-
| [
|
|
87
|
+
| [PickContainsValue](./type-tls.pickcontainsvalue.md) | 从 Target 中挑选出那些成员值的类型包含 Value 类型的成员 |
|
|
88
|
+
| [PickMethod](./type-tls.pickmethod.md) | 从 Target 中挑选出方法 |
|
|
89
|
+
| [PickNonContainsValue](./type-tls.picknoncontainsvalue.md) | 从 Target 中挑选出那些成员值的类型不包含 Value 类型的成员 |
|
|
90
|
+
| [PickNonValue](./type-tls.picknonvalue.md) | 从 Target 中挑选出那些成员值不是 Value 的类型的成员 |
|
|
91
|
+
| [PickProperty](./type-tls.pickproperty.md) | 从 Target 中挑选出属性 |
|
|
92
|
+
| [PickValue](./type-tls.pickvalue.md) | 从 T 中挑选出那些成员值为 Value 的类型的成员 |
|
|
97
93
|
| [Replace](./type-tls.replace.md) | 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType |
|
|
98
94
|
| [ReplaceNull](./type-tls.replacenull.md) | 可将源类型 SourType 中的 null 替换为 新的类型 NewType |
|
|
99
95
|
| [ReplaceUndefined](./type-tls.replaceundefined.md) | 可将源类型 SourType 中的 undefined 替换为 新的类型 NewType |
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
## PickContainsValue type
|
|
6
6
|
|
|
7
|
-
从
|
|
7
|
+
从 Target 中挑选出那些成员值的类型包含 Value 类型的成员
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare type PickContainsValue<
|
|
13
|
-
[P in KeyOfContainsValue<
|
|
12
|
+
export declare type PickContainsValue<Target, Value> = {
|
|
13
|
+
[P in KeyOfContainsValue<Target, Value>]: Target[P];
|
|
14
14
|
};
|
|
15
15
|
```
|
|
16
16
|
<b>References:</b> [KeyOfContainsValue](./type-tls.keyofcontainsvalue.md)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [type-tls](./type-tls.md) > [PickMethod](./type-tls.pickmethod.md)
|
|
4
|
+
|
|
5
|
+
## PickMethod type
|
|
6
|
+
|
|
7
|
+
从 Target 中挑选出方法
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare type PickMethod<Target> = PickValue<Target, AnyFunction>;
|
|
13
|
+
```
|
|
14
|
+
<b>References:</b> [PickValue](./type-tls.pickvalue.md)<!-- -->, [AnyFunction](./type-tls.anyfunction.md)
|
|
15
|
+
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
## PickNonContainsValue type
|
|
6
6
|
|
|
7
|
-
从
|
|
7
|
+
从 Target 中挑选出那些成员值的类型不包含 Value 类型的成员
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare type PickNonContainsValue<
|
|
13
|
-
[P in KeyOfNonContainsValue<
|
|
12
|
+
export declare type PickNonContainsValue<Target, Value> = {
|
|
13
|
+
[P in KeyOfNonContainsValue<Target, Value>]: Target[P];
|
|
14
14
|
};
|
|
15
15
|
```
|
|
16
16
|
<b>References:</b> [KeyOfNonContainsValue](./type-tls.keyofnoncontainsvalue.md)
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
## PickNonValue type
|
|
6
6
|
|
|
7
|
-
从
|
|
7
|
+
从 Target 中挑选出那些成员值不是 Value 的类型的成员
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare type PickNonValue<
|
|
13
|
-
[P in KeyOfNonValue<
|
|
12
|
+
export declare type PickNonValue<Target, Value> = {
|
|
13
|
+
[P in KeyOfNonValue<Target, Value>]: Target[P];
|
|
14
14
|
};
|
|
15
15
|
```
|
|
16
16
|
<b>References:</b> [KeyOfNonValue](./type-tls.keyofnonvalue.md)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [type-tls](./type-tls.md) > [PickProperty](./type-tls.pickproperty.md)
|
|
4
|
+
|
|
5
|
+
## PickProperty type
|
|
6
|
+
|
|
7
|
+
从 Target 中挑选出属性
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare type PickProperty<Target> = PickNonValue<Target, AnyFunction>;
|
|
13
|
+
```
|
|
14
|
+
<b>References:</b> [PickNonValue](./type-tls.picknonvalue.md)<!-- -->, [AnyFunction](./type-tls.anyfunction.md)
|
|
15
|
+
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
## PickValue type
|
|
6
6
|
|
|
7
|
-
从 T 中挑选出那些成员值为
|
|
7
|
+
从 T 中挑选出那些成员值为 Value 的类型的成员
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare type PickValue<
|
|
13
|
-
[P in KeyOfValue<
|
|
12
|
+
export declare type PickValue<Target, Value> = {
|
|
13
|
+
[P in KeyOfValue<Target, Value>]: Target[P];
|
|
14
14
|
};
|
|
15
15
|
```
|
|
16
16
|
<b>References:</b> [KeyOfValue](./type-tls.keyofvalue.md)
|