type-tls 2.4.0 → 2.4.3
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/async.d.ts +3 -3
- package/dist/base.d.ts +6 -0
- package/dist/type-tls.d.ts +10 -3
- package/dist/type-tls.es.js +4 -4
- package/dist/type-tls.iife.js +1 -1
- package/dist/type-tls.umd.js +1 -1
- package/doc/type-tls.keyofvalue.md +15 -0
- package/doc/type-tls.md +1 -0
- package/doc/type-tls.waitasyncable.md +2 -2
- package/doc/type-tls.waitasyncablecallback.md +1 -3
- package/doc/type-tls.waitasyncablereturn.md +1 -1
- package/package.json +2 -2
package/dist/async.d.ts
CHANGED
|
@@ -7,13 +7,13 @@ export declare type ResolveData<P> = P extends Promise<infer D> ? D : P;
|
|
|
7
7
|
/**
|
|
8
8
|
* waitAsyncable 的返回值的类型
|
|
9
9
|
*/
|
|
10
|
-
export declare type WaitAsyncableReturn<Result> =
|
|
10
|
+
export declare type WaitAsyncableReturn<Result, Return> = Return extends Promise<any> ? Return : (Result extends Promise<any> ? Promise<Return> : Return);
|
|
11
11
|
/**
|
|
12
12
|
* waitAsyncable 的回调函数的类型
|
|
13
13
|
* @param result - 同步的结果
|
|
14
14
|
* @param rejected - 异步是否被拒绝
|
|
15
15
|
*/
|
|
16
|
-
export declare type WaitAsyncableCallback<Result, Return> = (result:
|
|
16
|
+
export declare type WaitAsyncableCallback<Result, Return> = (result: Result | undefined, rejected: boolean, error: any) => Return;
|
|
17
17
|
/**
|
|
18
18
|
* 等待可异步的结果
|
|
19
19
|
*
|
|
@@ -25,4 +25,4 @@ export declare type WaitAsyncableCallback<Result, Return> = (result: ResolveData
|
|
|
25
25
|
* @param callback
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
|
-
export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Return>;
|
|
28
|
+
export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Result, Return>;
|
package/dist/base.d.ts
CHANGED
|
@@ -166,6 +166,12 @@ export declare type Optional<T> = T | null | undefined;
|
|
|
166
166
|
* 可选的布尔类型
|
|
167
167
|
*/
|
|
168
168
|
export declare type OptionalBoolean = Optional<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* 获取值类型为指定类型的所有 key
|
|
171
|
+
*/
|
|
172
|
+
export declare type KeyOfValue<Target, Value> = {
|
|
173
|
+
[K in keyof Target]: Target[K] extends Value ? K : never;
|
|
174
|
+
}[keyof Target];
|
|
169
175
|
/**
|
|
170
176
|
* 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType
|
|
171
177
|
*/
|
package/dist/type-tls.d.ts
CHANGED
|
@@ -312,6 +312,13 @@ export declare function isIterator(target: any): boolean;
|
|
|
312
312
|
*/
|
|
313
313
|
export declare function isObject(target: any): boolean;
|
|
314
314
|
|
|
315
|
+
/**
|
|
316
|
+
* 获取值类型为指定类型的所有 key
|
|
317
|
+
*/
|
|
318
|
+
export declare type KeyOfValue<Target, Value> = {
|
|
319
|
+
[K in keyof Target]: Target[K] extends Value ? K : never;
|
|
320
|
+
}[keyof Target];
|
|
321
|
+
|
|
315
322
|
/**
|
|
316
323
|
* 宽松的类型
|
|
317
324
|
*/
|
|
@@ -488,18 +495,18 @@ export declare type TypeOfReturnType = "string" | "number" | "bigint" | "boolean
|
|
|
488
495
|
* @param callback
|
|
489
496
|
* @returns
|
|
490
497
|
*/
|
|
491
|
-
export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Return>;
|
|
498
|
+
export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Result, Return>;
|
|
492
499
|
|
|
493
500
|
/**
|
|
494
501
|
* waitAsyncable 的回调函数的类型
|
|
495
502
|
* @param result - 同步的结果
|
|
496
503
|
* @param rejected - 异步是否被拒绝
|
|
497
504
|
*/
|
|
498
|
-
export declare type WaitAsyncableCallback<Result, Return> = (result:
|
|
505
|
+
export declare type WaitAsyncableCallback<Result, Return> = (result: Result | undefined, rejected: boolean, error: any) => Return;
|
|
499
506
|
|
|
500
507
|
/**
|
|
501
508
|
* waitAsyncable 的返回值的类型
|
|
502
509
|
*/
|
|
503
|
-
export declare type WaitAsyncableReturn<Result> =
|
|
510
|
+
export declare type WaitAsyncableReturn<Result, Return> = Return extends Promise<any> ? Return : (Result extends Promise<any> ? Promise<Return> : Return);
|
|
504
511
|
|
|
505
512
|
export { }
|
package/dist/type-tls.es.js
CHANGED
|
@@ -161,11 +161,11 @@ function isAnonymousFunction(fun) {
|
|
|
161
161
|
function waitAsyncable(asyncable, callback) {
|
|
162
162
|
if (asyncable instanceof Promise) {
|
|
163
163
|
return asyncable.then((syncRes) => {
|
|
164
|
-
return callback(syncRes, false);
|
|
165
|
-
}, () => {
|
|
166
|
-
return callback(void 0, true);
|
|
164
|
+
return callback(syncRes, false, void 0);
|
|
165
|
+
}, (error) => {
|
|
166
|
+
return callback(void 0, true, error);
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
return callback(asyncable, false);
|
|
169
|
+
return callback(asyncable, false, void 0);
|
|
170
170
|
}
|
|
171
171
|
export { createDefineMixin, createExtendTarget, createMixinTarget, createTargetExtend, createTargetMixin, defineExtend, defineMixin, extendTarget, getExactTypeNameOf, getExactTypeOf, getNameOfType, getTypeByName, getTypeNameOf, getTypeOf, isAnonymousFunction, isArrayLike, isArrowFunction, isAsyncFunction, isAsyncGeneratorFunction, isBaseType, isGeneratorFunction, isIdentifier, isIterable, isIterator, isObject, mixin, mixinTarget, targetExtend, targetMixin, waitAsyncable };
|
package/dist/type-tls.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var TypeTls=function(e){var y,g,T;"use strict";function a(n){var t=typeof n;return n&&(t==="object"||t==="function")}function o(n){var t=n;return n!=null&&(t=n.constructor,t==null&&(t=typeof n)),t}function f(n){switch(n){case void 0:return"undefined";case null:return"null"}let t=typeof n;switch(t){case"function":return n.name;case"string":return n;default:return t}}function l(n){return globalThis[n]}function A(n){let t=o(n);return f(t)}function s(n){return n==null||a(n)?o(n):typeof n}function b(n){var t=s(n);return f(t)}function m(n){var t=typeof n;return n==null||t!=="object"&&t!=="function"}function F(n){let t=n&&n.length;return Number.isInteger(n.length)&&t>=0}function O(n){return n&&typeof n[Symbol.iterator]=="function"}function E(n){return n&&typeof n.next=="function"}function i(n,...t){for(const r of t){const c=Object.getOwnPropertyDescriptors(r);Object.defineProperties(n,c)}return n}function M(n,t){return t}function w(){return function(t,r){return r}}function _(n,t){return i(n,t),t}function v(n){return function(r){return i(n,r),r}}function h(n,t){return i(n,t),n}function $(n){return function(r){return i(n,r),n}}function N(n,t){return t}function u(n,t){var c;i(n.prototype,t);const r=t._constructor;if(typeof r=="function"){const d=n;((c=d._constructors)!=null?c:d._constructors=[]).push(r)}return t}function S(n){return function(r){return u(n,r),r}}function I(n,t){return u(n,t),n}function j(n){return function(r){return u(n,r),n}}const G=/^[A-Za-z_$]+[\w$]*$/;function p(n){return G.test(n)}const z=/(^\s*(async\s+)?\s*(\b[A-Za-z_$]+[\w$]*\b)\s*=>)|(^\s*(async\s+)?\s*\(\s*(\b[A-Za-z_$]+[\w$]*\b)?\s*(,\s*(\b[A-Za-z_$]+[\w$]*\b)\s*)*\)\s*=>)/;function Z(n){const t=n.toString();return z.test(t)}const B=(y=globalThis.AsyncFunction)!=null?y:async function(){}.constructor;function D(n){return n instanceof B}const P=(g=globalThis.GeneratorFunction)!=null?g:function*(){}.constructor;function x(n){return n instanceof P}const L=(T=globalThis.AsyncGeneratorFunction)!=null?T:async function*(){}.constructor;function R(n){return n instanceof L}const k=/(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;function q(n){if(n.name){const t=n.toString();return!k.test(t)}return!0}function C(n,t){return n instanceof Promise?n.then(r=>t(r,!1,void 0),r=>t(void 0,!0,r)):t(n,!1,void 0)}return e.createDefineMixin=w,e.createExtendTarget=j,e.createMixinTarget=$,e.createTargetExtend=S,e.createTargetMixin=v,e.defineExtend=N,e.defineMixin=M,e.extendTarget=I,e.getExactTypeNameOf=b,e.getExactTypeOf=s,e.getNameOfType=f,e.getTypeByName=l,e.getTypeNameOf=A,e.getTypeOf=o,e.isAnonymousFunction=q,e.isArrayLike=F,e.isArrowFunction=Z,e.isAsyncFunction=D,e.isAsyncGeneratorFunction=R,e.isBaseType=m,e.isGeneratorFunction=x,e.isIdentifier=p,e.isIterable=O,e.isIterator=E,e.isObject=a,e.mixin=i,e.mixinTarget=h,e.targetExtend=u,e.targetMixin=_,e.waitAsyncable=C,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),e}({});
|
package/dist/type-tls.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(e=typeof globalThis!="undefined"?globalThis:e||self,r(e.
|
|
1
|
+
(function(e,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(e=typeof globalThis!="undefined"?globalThis:e||self,r(e.TypeTls={}))})(this,function(e){var y,g,d;"use strict";function r(n){var t=typeof n;return n&&(t==="object"||t==="function")}function f(n){var t=n;return n!=null&&(t=n.constructor,t==null&&(t=typeof n)),t}function s(n){switch(n){case void 0:return"undefined";case null:return"null"}let t=typeof n;switch(t){case"function":return n.name;case"string":return n;default:return t}}function l(n){return globalThis[n]}function m(n){let t=f(n);return s(t)}function a(n){return n==null||r(n)?f(n):typeof n}function b(n){var t=a(n);return s(t)}function A(n){var t=typeof n;return n==null||t!=="object"&&t!=="function"}function F(n){let t=n&&n.length;return Number.isInteger(n.length)&&t>=0}function O(n){return n&&typeof n[Symbol.iterator]=="function"}function p(n){return n&&typeof n.next=="function"}function u(n,...t){for(const i of t){const o=Object.getOwnPropertyDescriptors(i);Object.defineProperties(n,o)}return n}function E(n,t){return t}function h(){return function(t,i){return i}}function M(n,t){return u(n,t),t}function w(n){return function(i){return u(n,i),i}}function _(n,t){return u(n,t),n}function v(n){return function(i){return u(n,i),n}}function $(n,t){return t}function c(n,t){var o;u(n.prototype,t);const i=t._constructor;if(typeof i=="function"){const T=n;((o=T._constructors)!=null?o:T._constructors=[]).push(i)}return t}function N(n){return function(i){return c(n,i),i}}function S(n,t){return c(n,t),n}function j(n){return function(i){return c(n,i),n}}const I=/^[A-Za-z_$]+[\w$]*$/;function G(n){return I.test(n)}const x=/(^\s*(async\s+)?\s*(\b[A-Za-z_$]+[\w$]*\b)\s*=>)|(^\s*(async\s+)?\s*\(\s*(\b[A-Za-z_$]+[\w$]*\b)?\s*(,\s*(\b[A-Za-z_$]+[\w$]*\b)\s*)*\)\s*=>)/;function z(n){const t=n.toString();return x.test(t)}const Z=(y=globalThis.AsyncFunction)!=null?y:async function(){}.constructor;function B(n){return n instanceof Z}const D=(g=globalThis.GeneratorFunction)!=null?g:function*(){}.constructor;function P(n){return n instanceof D}const L=(d=globalThis.AsyncGeneratorFunction)!=null?d:async function*(){}.constructor;function R(n){return n instanceof L}const k=/(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;function q(n){if(n.name){const t=n.toString();return!k.test(t)}return!0}function C(n,t){return n instanceof Promise?n.then(i=>t(i,!1,void 0),i=>t(void 0,!0,i)):t(n,!1,void 0)}e.createDefineMixin=h,e.createExtendTarget=j,e.createMixinTarget=v,e.createTargetExtend=N,e.createTargetMixin=w,e.defineExtend=$,e.defineMixin=E,e.extendTarget=S,e.getExactTypeNameOf=b,e.getExactTypeOf=a,e.getNameOfType=s,e.getTypeByName=l,e.getTypeNameOf=m,e.getTypeOf=f,e.isAnonymousFunction=q,e.isArrayLike=F,e.isArrowFunction=z,e.isAsyncFunction=B,e.isAsyncGeneratorFunction=R,e.isBaseType=A,e.isGeneratorFunction=P,e.isIdentifier=G,e.isIterable=O,e.isIterator=p,e.isObject=r,e.mixin=u,e.mixinTarget=_,e.targetExtend=c,e.targetMixin=M,e.waitAsyncable=C,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -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) > [KeyOfValue](./type-tls.keyofvalue.md)
|
|
4
|
+
|
|
5
|
+
## KeyOfValue type
|
|
6
|
+
|
|
7
|
+
获取值类型为指定类型的所有 key
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare type KeyOfValue<Target, Value> = {
|
|
13
|
+
[K in keyof Target]: Target[K] extends Value ? K : never;
|
|
14
|
+
}[keyof Target];
|
|
15
|
+
```
|
package/doc/type-tls.md
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
| [AnyFunction](./type-tls.anyfunction.md) | 表示任意的函数类型 |
|
|
54
54
|
| [ExactType](./type-tls.exacttype.md) | 精确类型 |
|
|
55
55
|
| [ExactTypeName](./type-tls.exacttypename.md) | 精确类型的字符串表示 |
|
|
56
|
+
| [KeyOfValue](./type-tls.keyofvalue.md) | 获取值类型为指定类型的所有 key |
|
|
56
57
|
| [LooseType](./type-tls.loosetype.md) | 宽松的类型 |
|
|
57
58
|
| [LooseTypeName](./type-tls.loosetypename.md) | 宽松类型的字符串表示 |
|
|
58
59
|
| [MethodParams](./type-tls.methodparams.md) | 获取对象的方法的某个参数的类型 |
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Return>;
|
|
12
|
+
export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Result, Return>;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
@@ -21,7 +21,7 @@ export declare function waitAsyncable<Result, Return>(asyncable: Result, callbac
|
|
|
21
21
|
|
|
22
22
|
<b>Returns:</b>
|
|
23
23
|
|
|
24
|
-
[WaitAsyncableReturn](./type-tls.waitasyncablereturn.md)<!-- --><Return>
|
|
24
|
+
[WaitAsyncableReturn](./type-tls.waitasyncablereturn.md)<!-- --><Result, Return>
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
## Remarks
|
|
@@ -9,7 +9,5 @@ waitAsyncable 的回调函数的类型
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare type WaitAsyncableCallback<Result, Return> = (result:
|
|
12
|
+
export declare type WaitAsyncableCallback<Result, Return> = (result: Result | undefined, rejected: boolean, error: any) => Return;
|
|
13
13
|
```
|
|
14
|
-
<b>References:</b> [ResolveData](./type-tls.resolvedata.md)
|
|
15
|
-
|
|
@@ -9,5 +9,5 @@ waitAsyncable 的返回值的类型
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare type WaitAsyncableReturn<Result> =
|
|
12
|
+
export declare type WaitAsyncableReturn<Result, Return> = Return extends Promise<any> ? Return : (Result extends Promise<any> ? Promise<Return> : Return);
|
|
13
13
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-tls",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "type-tls 封装了与类型相关的工具,比如:获取数据的类型 或 类型名字、判断数据的类型 等",
|
|
5
5
|
"main": "dist/type-tls.umd.js",
|
|
6
6
|
"module": "dist/type-tls.es.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@microsoft/api-extractor": "^7.24.1",
|
|
47
47
|
"build-tls": "^1.3.11",
|
|
48
48
|
"dts-bundle-generator": "^6.12.0",
|
|
49
|
-
"package-tls": "^1.
|
|
49
|
+
"package-tls": "^1.3.1",
|
|
50
50
|
"typescript": "^4.5.4",
|
|
51
51
|
"vite": "^2.9.9"
|
|
52
52
|
}
|