type-tls 2.4.3 → 2.4.4

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 (70) hide show
  1. package/README.md +9 -3
  2. package/dist/index.d.ts +466 -6
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/dist/type-tls.d.ts +24 -16
  5. package/dist/type-tls.mjs +180 -0
  6. package/dist/type-tls.umd.js +1 -1
  7. package/doc/{index.md → api/index.md} +1 -1
  8. package/doc/{type-tls.anyfunction.md → api/type-tls.anyfunction.md} +0 -0
  9. package/doc/{type-tls.classtype._new_.md → api/type-tls.classtype._new_.md} +0 -0
  10. package/doc/{type-tls.classtype.md → api/type-tls.classtype.md} +0 -0
  11. package/doc/{type-tls.createdefinemixin.md → api/type-tls.createdefinemixin.md} +0 -0
  12. package/doc/{type-tls.createextendtarget.md → api/type-tls.createextendtarget.md} +0 -0
  13. package/doc/{type-tls.createmixintarget.md → api/type-tls.createmixintarget.md} +0 -0
  14. package/doc/{type-tls.createtargetextend.md → api/type-tls.createtargetextend.md} +0 -0
  15. package/doc/{type-tls.createtargetmixin.md → api/type-tls.createtargetmixin.md} +0 -0
  16. package/doc/{type-tls.defineextend.md → api/type-tls.defineextend.md} +0 -0
  17. package/doc/{type-tls.definemixin.md → api/type-tls.definemixin.md} +0 -0
  18. package/doc/{type-tls.exacttype.md → api/type-tls.exacttype.md} +0 -0
  19. package/doc/{type-tls.exacttypename.md → api/type-tls.exacttypename.md} +0 -0
  20. package/doc/{type-tls.extendtarget.md → api/type-tls.extendtarget.md} +0 -0
  21. package/doc/{type-tls.getexacttypenameof.md → api/type-tls.getexacttypenameof.md} +0 -0
  22. package/doc/{type-tls.getexacttypeof.md → api/type-tls.getexacttypeof.md} +0 -0
  23. package/doc/{type-tls.getnameoftype.md → api/type-tls.getnameoftype.md} +0 -0
  24. package/doc/{type-tls.gettypebyname.md → api/type-tls.gettypebyname.md} +0 -0
  25. package/doc/{type-tls.gettypenameof.md → api/type-tls.gettypenameof.md} +0 -0
  26. package/doc/{type-tls.gettypeof.md → api/type-tls.gettypeof.md} +0 -0
  27. package/doc/{type-tls.isanonymousfunction.md → api/type-tls.isanonymousfunction.md} +0 -0
  28. package/doc/{type-tls.isarraylike.md → api/type-tls.isarraylike.md} +0 -0
  29. package/doc/{type-tls.isarrowfunction.md → api/type-tls.isarrowfunction.md} +0 -0
  30. package/doc/{type-tls.isasyncfunction.md → api/type-tls.isasyncfunction.md} +0 -0
  31. package/doc/{type-tls.isasyncgeneratorfunction.md → api/type-tls.isasyncgeneratorfunction.md} +0 -0
  32. package/doc/{type-tls.isbasetype.md → api/type-tls.isbasetype.md} +0 -0
  33. package/doc/{type-tls.isgeneratorfunction.md → api/type-tls.isgeneratorfunction.md} +0 -0
  34. package/doc/{type-tls.isidentifier.md → api/type-tls.isidentifier.md} +0 -0
  35. package/doc/{type-tls.isiterable.md → api/type-tls.isiterable.md} +0 -0
  36. package/doc/{type-tls.isiterator.md → api/type-tls.isiterator.md} +0 -0
  37. package/doc/{type-tls.isobject.md → api/type-tls.isobject.md} +0 -0
  38. package/doc/{type-tls.keyofvalue.md → api/type-tls.keyofvalue.md} +1 -1
  39. package/doc/{type-tls.loosetype.md → api/type-tls.loosetype.md} +0 -0
  40. package/doc/{type-tls.loosetypename.md → api/type-tls.loosetypename.md} +0 -0
  41. package/doc/{type-tls.md → api/type-tls.md} +6 -0
  42. package/doc/{type-tls.methodparams.md → api/type-tls.methodparams.md} +0 -0
  43. package/doc/{type-tls.methodreturntype.md → api/type-tls.methodreturntype.md} +0 -0
  44. package/doc/{type-tls.mixin_4.md → api/type-tls.mixin_4.md} +0 -0
  45. package/doc/{type-tls.mixintarget.md → api/type-tls.mixintarget.md} +0 -0
  46. package/doc/{type-tls.optional.md → api/type-tls.optional.md} +0 -0
  47. package/doc/{type-tls.optionalboolean.md → api/type-tls.optionalboolean.md} +0 -0
  48. package/doc/{type-tls.privatememberofextend._constructor.md → api/type-tls.privatememberofextend._constructor.md} +0 -0
  49. package/doc/{type-tls.privatememberofextend.md → api/type-tls.privatememberofextend.md} +0 -0
  50. package/doc/{type-tls.replace.md → api/type-tls.replace.md} +0 -0
  51. package/doc/{type-tls.replacenull.md → api/type-tls.replacenull.md} +0 -0
  52. package/doc/{type-tls.replaceundefined.md → api/type-tls.replaceundefined.md} +0 -0
  53. package/doc/{type-tls.replacevoid.md → api/type-tls.replacevoid.md} +0 -0
  54. package/doc/{type-tls.resolvedata.md → api/type-tls.resolvedata.md} +0 -0
  55. package/doc/{type-tls.targetextend.md → api/type-tls.targetextend.md} +0 -0
  56. package/doc/{type-tls.targetmixin.md → api/type-tls.targetmixin.md} +0 -0
  57. package/doc/{type-tls.typeofreturntype.md → api/type-tls.typeofreturntype.md} +0 -0
  58. package/doc/{type-tls.waitasyncable.md → api/type-tls.waitasyncable.md} +0 -0
  59. package/doc/{type-tls.waitasyncablecallback.md → api/type-tls.waitasyncablecallback.md} +3 -1
  60. package/doc/{type-tls.waitasyncablereturn.md → api/type-tls.waitasyncablereturn.md} +0 -0
  61. package/doc//346/225/231/347/250/213.md +7 -0
  62. package/package.json +12 -12
  63. package/dist/async.d.ts +0 -28
  64. package/dist/base.d.ts +0 -190
  65. package/dist/buffer.d.ts +0 -1
  66. package/dist/extend.d.ts +0 -86
  67. package/dist/function.d.ts +0 -49
  68. package/dist/member.d.ts +0 -16
  69. package/dist/mixin.d.ts +0 -96
  70. package/dist/type-tls.es.js +0 -171
@@ -0,0 +1,180 @@
1
+ function p(n) {
2
+ var t = typeof n;
3
+ return n && (t === "object" || t === "function");
4
+ }
5
+ function a(n) {
6
+ var t = n;
7
+ return n != null && (t = n.constructor, t == null && (t = typeof n)), t;
8
+ }
9
+ function y(n) {
10
+ switch (n) {
11
+ case void 0:
12
+ return "undefined";
13
+ case null:
14
+ return "null";
15
+ }
16
+ let t = typeof n;
17
+ switch (t) {
18
+ case "function":
19
+ return n.name;
20
+ case "string":
21
+ return n;
22
+ default:
23
+ return t;
24
+ }
25
+ }
26
+ function m(n) {
27
+ return globalThis[n];
28
+ }
29
+ function h(n) {
30
+ let t = a(n);
31
+ return y(t);
32
+ }
33
+ function g(n) {
34
+ return n == null || p(n) ? a(n) : typeof n;
35
+ }
36
+ function w(n) {
37
+ var t = g(n);
38
+ return y(t);
39
+ }
40
+ function O(n) {
41
+ var t = typeof n;
42
+ return n == null || t !== "object" && t !== "function";
43
+ }
44
+ function _(n) {
45
+ let t = n && n.length;
46
+ return Number.isInteger(n.length) && t >= 0;
47
+ }
48
+ function $(n) {
49
+ return n && typeof n[Symbol.iterator] == "function";
50
+ }
51
+ function v(n) {
52
+ return n && typeof n.next == "function";
53
+ }
54
+ function r(n, ...t) {
55
+ for (const e of t) {
56
+ const o = Object.getOwnPropertyDescriptors(e);
57
+ Object.defineProperties(n, o);
58
+ }
59
+ return n;
60
+ }
61
+ function E(n, t) {
62
+ return t;
63
+ }
64
+ function S() {
65
+ return function(t, e) {
66
+ return e;
67
+ };
68
+ }
69
+ function M(n, t) {
70
+ return r(n, t), t;
71
+ }
72
+ function j(n) {
73
+ return function(e) {
74
+ return r(n, e), e;
75
+ };
76
+ }
77
+ function G(n, t) {
78
+ return r(n, t), n;
79
+ }
80
+ function I(n) {
81
+ return function(e) {
82
+ return r(n, e), n;
83
+ };
84
+ }
85
+ function N(n, t) {
86
+ return t;
87
+ }
88
+ function u(n, t) {
89
+ var o;
90
+ r(n.prototype, t);
91
+ const e = t._constructor;
92
+ if (typeof e == "function") {
93
+ const i = n;
94
+ ((o = i._constructors) != null ? o : i._constructors = []).push(e);
95
+ }
96
+ return t;
97
+ }
98
+ function z(n) {
99
+ return function(e) {
100
+ return u(n, e), e;
101
+ };
102
+ }
103
+ function Z(n, t) {
104
+ return u(n, t), n;
105
+ }
106
+ function D(n) {
107
+ return function(e) {
108
+ return u(n, e), n;
109
+ };
110
+ }
111
+ const l = /^[A-Za-z_$]+[\w$]*$/;
112
+ function P(n) {
113
+ return l.test(n);
114
+ }
115
+ const T = /(^\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*=>)/;
116
+ function B(n) {
117
+ const t = n.toString();
118
+ return T.test(t);
119
+ }
120
+ var c;
121
+ const d = (c = globalThis.AsyncFunction) != null ? c : async function() {
122
+ }.constructor;
123
+ function R(n) {
124
+ return n instanceof d;
125
+ }
126
+ var s;
127
+ const x = (s = globalThis.GeneratorFunction) != null ? s : function* () {
128
+ }.constructor;
129
+ function L(n) {
130
+ return n instanceof x;
131
+ }
132
+ var f;
133
+ const b = (f = globalThis.AsyncGeneratorFunction) != null ? f : async function* () {
134
+ }.constructor;
135
+ function q(n) {
136
+ return n instanceof b;
137
+ }
138
+ const A = /(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;
139
+ function C(n) {
140
+ if (n.name) {
141
+ const t = n.toString();
142
+ return !A.test(t);
143
+ }
144
+ return !0;
145
+ }
146
+ function H(n, t) {
147
+ return n instanceof Promise ? n.then((e) => t(e, !1, void 0), (e) => t(void 0, !0, e)) : t(n, !1, void 0);
148
+ }
149
+ export {
150
+ S as createDefineMixin,
151
+ D as createExtendTarget,
152
+ I as createMixinTarget,
153
+ z as createTargetExtend,
154
+ j as createTargetMixin,
155
+ N as defineExtend,
156
+ E as defineMixin,
157
+ Z as extendTarget,
158
+ w as getExactTypeNameOf,
159
+ g as getExactTypeOf,
160
+ y as getNameOfType,
161
+ m as getTypeByName,
162
+ h as getTypeNameOf,
163
+ a as getTypeOf,
164
+ C as isAnonymousFunction,
165
+ _ as isArrayLike,
166
+ B as isArrowFunction,
167
+ R as isAsyncFunction,
168
+ q as isAsyncGeneratorFunction,
169
+ O as isBaseType,
170
+ L as isGeneratorFunction,
171
+ P as isIdentifier,
172
+ $ as isIterable,
173
+ v as isIterator,
174
+ p as isObject,
175
+ r as mixin,
176
+ G as mixinTarget,
177
+ u as targetExtend,
178
+ M as targetMixin,
179
+ H as waitAsyncable
180
+ };
@@ -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.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"}})});
1
+ (function(e,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(e=typeof globalThis<"u"?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"}})});
@@ -8,5 +8,5 @@
8
8
 
9
9
  | Package | Description |
10
10
  | --- | --- |
11
- | [type-tls](./type-tls.md) | |
11
+ | [type-tls](./type-tls.md) | 处理类型相关的工具 |
12
12
 
@@ -10,6 +10,6 @@
10
10
 
11
11
  ```typescript
12
12
  export declare type KeyOfValue<Target, Value> = {
13
- [K in keyof Target]: Target[K] extends Value ? K : never;
13
+ [K in keyof Target]: Target[K] extends Value ? K : never;
14
14
  }[keyof Target];
15
15
  ```
@@ -4,6 +4,12 @@
4
4
 
5
5
  ## type-tls package
6
6
 
7
+ 处理类型相关的工具
8
+
9
+ ## Remarks
10
+
11
+ type-tls 封装了与类型相关的工具,比如获取数据的类型 或 类型名字、判断数据的类型 等
12
+
7
13
  ## Functions
8
14
 
9
15
  | Function | Description |
@@ -9,5 +9,7 @@ waitAsyncable 的回调函数的类型
9
9
  <b>Signature:</b>
10
10
 
11
11
  ```typescript
12
- export declare type WaitAsyncableCallback<Result, Return> = (result: Result | undefined, rejected: boolean, error: any) => Return;
12
+ export declare type WaitAsyncableCallback<Result, Return> = (result: ResolveData<Result> | undefined, rejected: boolean, error: any) => Return;
13
13
  ```
14
+ <b>References:</b> [ResolveData](./type-tls.resolvedata.md)
15
+
@@ -0,0 +1,7 @@
1
+ [API接口文档]: ./api/index.md
2
+
3
+ > 由于时间关系,暂时还未编写教程,以后会抽空补齐。详情可查看[API接口文档][]。
4
+
5
+ > 开源不易,还望多多支持!💖 💖 💖
6
+
7
+ ![赞赏码](https://i.loli.net/2020/04/08/PGsAEqdJCin1oQL.jpg)
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "type-tls",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "type-tls 封装了与类型相关的工具,比如:获取数据的类型 或 类型名字、判断数据的类型 等",
5
5
  "main": "dist/type-tls.umd.js",
6
- "module": "dist/type-tls.es.js",
6
+ "module": "dist/type-tls.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "homepage": "https://github.com/GuoBinyong/type-tls#readme",
@@ -33,14 +33,6 @@
33
33
  "docs/[^.]*",
34
34
  "doc/[^.]*"
35
35
  ],
36
- "scripts": {
37
- "dev": "vite",
38
- "build": "vite build",
39
- "bunch": "vite build --mode bunch",
40
- "preview": "vite preview",
41
- "api": "api-extractor run -c api-extractor.jsonc -l -v",
42
- "doc": "npm run api ; api-documenter markdown -i ./temp -o doc"
43
- },
44
36
  "devDependencies": {
45
37
  "@microsoft/api-documenter": "^7.17.15",
46
38
  "@microsoft/api-extractor": "^7.24.1",
@@ -48,6 +40,14 @@
48
40
  "dts-bundle-generator": "^6.12.0",
49
41
  "package-tls": "^1.3.1",
50
42
  "typescript": "^4.5.4",
51
- "vite": "^2.9.9"
43
+ "vite": "^3.0.9"
44
+ },
45
+ "scripts": {
46
+ "dev": "vite",
47
+ "build": "vite build",
48
+ "bunch": "vite build --mode bunch",
49
+ "preview": "vite preview",
50
+ "api": "api-extractor run -c api-extractor.jsonc -l -v",
51
+ "doc": "npm run api ; api-documenter markdown -i ./temp -o doc/api"
52
52
  }
53
- }
53
+ }
package/dist/async.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * 获取 Promise 解决的类型的值
3
- * @remarks
4
- * 对于非 Promise 类型的值,返回原类型本身
5
- */
6
- export declare type ResolveData<P> = P extends Promise<infer D> ? D : P;
7
- /**
8
- * waitAsyncable 的返回值的类型
9
- */
10
- export declare type WaitAsyncableReturn<Result, Return> = Return extends Promise<any> ? Return : (Result extends Promise<any> ? Promise<Return> : Return);
11
- /**
12
- * waitAsyncable 的回调函数的类型
13
- * @param result - 同步的结果
14
- * @param rejected - 异步是否被拒绝
15
- */
16
- export declare type WaitAsyncableCallback<Result, Return> = (result: Result | undefined, rejected: boolean, error: any) => Return;
17
- /**
18
- * 等待可异步的结果
19
- *
20
- * @remarks
21
- * 当 asyncable 为同步值时,会同步调用 callback。
22
- * 当 asyncable 为异步值时,会等待 asyncable 解决后再调用 callback。
23
- *
24
- * @param asyncable - 可异步的结果
25
- * @param callback
26
- * @returns
27
- */
28
- export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Result, Return>;
package/dist/base.d.ts DELETED
@@ -1,190 +0,0 @@
1
- /**
2
- * 处理类型相关的工具
3
- * @remarks
4
- * type-tls 封装了与类型相关的工具,比如获取数据的类型 或 类型名字、判断数据的类型 等
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * 判断目标是否是对象类型
10
- *
11
- * @remarks
12
- * 仅通过 target instanceof Object 判断是不行的,因为 对于 Object.create(null) 创建的对象 通过 ` Object.create(null) instanceof Object ` 来判断 返回的是 false
13
- * 即:通过 Object.create(null) 创建的对象是不被 instanceof 认为是继续于 Object 的
14
- *
15
- * typeof null 也返回 "object"
16
- *
17
- * @param target : any 目标对象
18
- */
19
- export declare function isObject(target: any): boolean;
20
- /**
21
- * typeof 的返回类型
22
- */
23
- export declare type TypeOfReturnType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
24
- /**
25
- * 宽松的类型
26
- */
27
- export declare type LooseType = undefined | null | Function | "object";
28
- /**
29
- * 宽松类型的字符串表示
30
- */
31
- export declare type LooseTypeName = "undefined" | "null" | "Function" | "object" | string;
32
- /**
33
- * 精确类型
34
- *
35
- * @remarks
36
- * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
37
- * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
38
- * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
39
- * 但,对于 undefined 和 null 会返回其自身值(即 undefined 和 null)作为类型值
40
- *
41
- * 各种类型的值 与 该方法的返回值 的映射如下:
42
- * ```
43
- * undefined :undefined
44
- * null : null
45
- * string : "string"
46
- * number : "number"
47
- * bigint : "bigint"
48
- * boolean : "boolean"
49
- * symbol : "symbol"
50
- * function : Function
51
- * 没有原型的对象(如:通过 `Object.create(null)` 创建的对象) : "object"
52
- * 其它任何类型的实例 : 返回该实例的构造函数
53
- * ```
54
- */
55
- export declare type ExactType = LooseType | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
56
- /**
57
- * 精确类型的字符串表示
58
- *
59
- * @remarks
60
- * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
61
- * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
62
- * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
63
- * 但,对于 null 会返回 "null"
64
- *
65
- * 各种类型的值 与 该方法的返回值 的映射如下:
66
- * ```
67
- * undefined :"undefined"
68
- * null : "null"
69
- * function : "Function"
70
- * string : "string"
71
- * number : "number"
72
- * bigint : "bigint"
73
- * boolean : "boolean"
74
- * symbol : "symbol"
75
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
76
- * 其它任何类型的实例 : 返回该实例的构造函数的名字
77
- * ```
78
- */
79
- export declare type ExactTypeName = LooseTypeName | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
80
- /**
81
- * 获取 inst 的宽松类型
82
- *
83
- * @remarks
84
- * 注意:
85
- * 本方法返回的结果如下:
86
- * ```
87
- * undefined :undefined
88
- * null : null
89
- * function : Function
90
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
91
- * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数
92
- * ```
93
- *
94
- *
95
- * @param inst
96
- * @returns inst 的类型
97
- */
98
- export declare function getTypeOf(inst: any): LooseType;
99
- /**
100
- * 获取 类型的字符串表示
101
- *
102
- * @param t - 一个 ExactType 类型的值
103
- * @return t 的字符串表示的类型
104
- */
105
- export declare function getNameOfType(t: ExactType): ExactTypeName;
106
- /**
107
- * 根据类型的名字获取其对应的类
108
- * @param typeName - 类型的名字
109
- */
110
- export declare function getTypeByName(typeName: string): Function | undefined;
111
- /**
112
- * 获取 inst 的类型字符串
113
- *
114
- * @remarks
115
- * 注意:
116
- * 本方法返回的结果如下:
117
- * undefined :"undefined"
118
- * null : "null"
119
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
120
- * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数 的函数名字
121
- *
122
- * @param inst
123
- * @returns inst 的类型字符串
124
- */
125
- export declare function getTypeNameOf(inst: any): LooseTypeName;
126
- /**
127
- * 获取 inst 的精确类型
128
- * @param inst
129
- * @returns inst 的类型
130
- */
131
- export declare function getExactTypeOf(inst: any): ExactType;
132
- /**
133
- * 获取 inst 的精确类型的字符串表示
134
- * @param inst
135
- * @returns inst 的类型字符串
136
- */
137
- export declare function getExactTypeNameOf(inst: any): ExactTypeName;
138
- /**
139
- * 判断 data 是否是 基本类型
140
- * @remarks
141
- * 基本类型 是指 那些不是 对象类型的类型,即,除了 object 和 function 类型以外,其它的都是基本类型,null 也算怎是 基本类型
142
- * @param data - 任意类型的值
143
- */
144
- export declare function isBaseType(data: any): boolean;
145
- /**
146
- * 判断 target 是否为 类数组对象
147
- * @param target - 目标
148
- * @returns
149
- */
150
- export declare function isArrayLike(target: any): boolean;
151
- /**
152
- * 判断 目标 是否是可迭代的对象,即 实现了 可迭代协议
153
- * @param target - 目标
154
- */
155
- export declare function isIterable(target: any): boolean;
156
- /**
157
- * 判断 目标 是否是迭代器,即 实现了 迭代器协议
158
- * @param target - 目标
159
- */
160
- export declare function isIterator(target: any): boolean;
161
- /**
162
- * 将某个类型变为可选的类型
163
- */
164
- export declare type Optional<T> = T | null | undefined;
165
- /**
166
- * 可选的布尔类型
167
- */
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];
175
- /**
176
- * 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType
177
- */
178
- export declare type Replace<SourType, MatchType, NewType> = SourType extends MatchType ? NewType : SourType;
179
- /**
180
- * 可将源类型 SourType 中的 undefined 替换为 新的类型 NewType
181
- */
182
- export declare type ReplaceUndefined<SourType, NewType> = Replace<SourType, undefined, NewType>;
183
- /**
184
- * 可将源类型 SourType 中的 null 替换为 新的类型 NewType
185
- */
186
- export declare type ReplaceNull<SourType, NewType> = Replace<SourType, null, NewType>;
187
- /**
188
- * 可将源类型 SourType 中的代表空的类型 void | undefined | null 替换为 新的类型 NewType
189
- */
190
- export declare type ReplaceVoid<SourType, NewType> = Replace<SourType, void | undefined | null, NewType>;
package/dist/buffer.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array | Float32Array | Float64Array;