type-tls 3.2.1 → 3.2.2
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/member.d.ts +18 -0
- package/dist/type-tls.d.ts +20 -0
- package/dist/type-tls.iife.js +1 -1
- package/dist/type-tls.js +44 -34
- package/dist/type-tls.umd.cjs +1 -1
- package/doc/api/type-tls.md +22 -0
- package/package.json +1 -1
package/dist/member.d.ts
CHANGED
|
@@ -26,6 +26,15 @@ export type ArrayItemType<Arr> = Arr extends (infer Item)[] ? Item : never;
|
|
|
26
26
|
* 如果 ItemOrArray 不是数组,则转为数组类型 ItemOrArray[]
|
|
27
27
|
*/
|
|
28
28
|
export type FormatAsArray<ItemOrArray> = ItemOrArray extends any[] ? ItemOrArray : ItemOrArray[];
|
|
29
|
+
/**
|
|
30
|
+
* 格式化为数组格式
|
|
31
|
+
* @remarks
|
|
32
|
+
* 如果 value 是数组,则保持不变
|
|
33
|
+
* 如果 value 不是数组,则转为数组类型
|
|
34
|
+
* @param value
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatAsArray<V>(value: V): FormatAsArray<V>;
|
|
29
38
|
/**
|
|
30
39
|
* 格式化对象成员为数组格式
|
|
31
40
|
* @remarks
|
|
@@ -35,3 +44,12 @@ export type FormatAsArray<ItemOrArray> = ItemOrArray extends any[] ? ItemOrArray
|
|
|
35
44
|
export type FormatMemberAsArray<D> = {
|
|
36
45
|
[K in keyof D]: FormatAsArray<D[K]>;
|
|
37
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* 格式化对象成员为数组格式
|
|
49
|
+
* @remarks
|
|
50
|
+
* 如果 成员 是数组,则保持不变
|
|
51
|
+
* 如果 成员 不是数组,则转为数组类型
|
|
52
|
+
*
|
|
53
|
+
* @returns 返回来的 data 对象,此方法会改变原对象 data,耗会生成新的对象
|
|
54
|
+
*/
|
|
55
|
+
export declare function formatMemberAsArray<D extends {}>(data: D): FormatMemberAsArray<D>;
|
package/dist/type-tls.d.ts
CHANGED
|
@@ -94,6 +94,16 @@ export declare type ExactTypeName = LooseTypeName | Exclude<TypeOfReturnType, "u
|
|
|
94
94
|
*/
|
|
95
95
|
export declare type FormatAsArray<ItemOrArray> = ItemOrArray extends any[] ? ItemOrArray : ItemOrArray[];
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* 格式化为数组格式
|
|
99
|
+
* @remarks
|
|
100
|
+
* 如果 value 是数组,则保持不变
|
|
101
|
+
* 如果 value 不是数组,则转为数组类型
|
|
102
|
+
* @param value
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
export declare function formatAsArray<V>(value: V): FormatAsArray<V>;
|
|
106
|
+
|
|
97
107
|
/**
|
|
98
108
|
* 格式化对象成员为数组格式
|
|
99
109
|
* @remarks
|
|
@@ -104,6 +114,16 @@ export declare type FormatMemberAsArray<D> = {
|
|
|
104
114
|
[K in keyof D]: FormatAsArray<D[K]>;
|
|
105
115
|
};
|
|
106
116
|
|
|
117
|
+
/**
|
|
118
|
+
* 格式化对象成员为数组格式
|
|
119
|
+
* @remarks
|
|
120
|
+
* 如果 成员 是数组,则保持不变
|
|
121
|
+
* 如果 成员 不是数组,则转为数组类型
|
|
122
|
+
*
|
|
123
|
+
* @returns 返回来的 data 对象,此方法会改变原对象 data,耗会生成新的对象
|
|
124
|
+
*/
|
|
125
|
+
export declare function formatMemberAsArray<D extends {}>(data: D): FormatMemberAsArray<D>;
|
|
126
|
+
|
|
107
127
|
/**
|
|
108
128
|
* 获取 inst 的精确类型的字符串表示
|
|
109
129
|
* @param inst
|
package/dist/type-tls.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var TypeTls=function(e){"use strict";function f(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 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 y(n){return globalThis[n]}function l(n){let t=o(n);return s(t)}function a(n){return n==null||f(n)?o(n):typeof n}function
|
|
1
|
+
var TypeTls=function(e){"use strict";function f(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 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 y(n){return globalThis[n]}function l(n){let t=o(n);return s(t)}function a(n){return n==null||f(n)?o(n):typeof n}function A(n){var t=a(n);return s(t)}function g(n){var t=typeof n;return n==null||t!=="object"&&t!=="function"}function T(n){let t=n&&n.length;return Number.isInteger(n.length)&&t>=0}function m(n){return n&&typeof n[Symbol.iterator]=="function"}function F(n){return n&&typeof n.next=="function"}const b=/^[A-Za-z_$]+[\w$]*$/;function O(n){return b.test(n)}const w=/(^\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 d(n){const t=n.toString();return w.test(t)}const h=globalThis.AsyncFunction??(async function(){}).constructor;function E(n){return n instanceof h}const $=globalThis.GeneratorFunction??(function*(){}).constructor;function N(n){return n instanceof $}const S=globalThis.AsyncGeneratorFunction??(async function*(){}).constructor;function q(n){return n instanceof S}const v=/(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;function I(n){if(n.name){const t=n.toString();return!v.test(t)}return!0}function G(n){return Array.isArray(n)?n:n==null?[]:[n]}function j(n){for(const[t,r]of Object.entries(n))n[t]=Array.isArray(r)?r:r==null?[]:[r];return n}function p(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.BitFlagEqualTestType=(n=>(n.equal="equal",n.intersect="intersect",n.intersectEqual="intersectEqual",n))(e.BitFlagEqualTestType||{}),(n=>{function t(r){let c;switch(r){case"equal":c=(u,i)=>u===i;case"intersect":c=(u,i)=>u&i;default:c=(u,i)=>(u&i)===u}return c}n.getEqualFun=t})(e.BitFlagEqualTestType||(e.BitFlagEqualTestType={})),e.formatAsArray=G,e.formatMemberAsArray=j,e.getExactTypeNameOf=A,e.getExactTypeOf=a,e.getNameOfType=s,e.getTypeByName=y,e.getTypeNameOf=l,e.getTypeOf=o,e.isAnonymousFunction=I,e.isArrayLike=T,e.isArrowFunction=d,e.isAsyncFunction=E,e.isAsyncGeneratorFunction=q,e.isBaseType=g,e.isGeneratorFunction=N,e.isIdentifier=O,e.isIterable=m,e.isIterator=F,e.isObject=f,e.waitAsyncable=p,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
package/dist/type-tls.js
CHANGED
|
@@ -23,17 +23,17 @@ function s(n) {
|
|
|
23
23
|
return t;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function m(n) {
|
|
27
27
|
return globalThis[n];
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function F(n) {
|
|
30
30
|
let t = i(n);
|
|
31
31
|
return s(t);
|
|
32
32
|
}
|
|
33
33
|
function a(n) {
|
|
34
34
|
return n == null || f(n) ? i(n) : typeof n;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function h(n) {
|
|
37
37
|
var t = a(n);
|
|
38
38
|
return s(t);
|
|
39
39
|
}
|
|
@@ -45,58 +45,66 @@ function $(n) {
|
|
|
45
45
|
let t = n && n.length;
|
|
46
46
|
return Number.isInteger(n.length) && t >= 0;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function O(n) {
|
|
49
49
|
return n && typeof n[Symbol.iterator] == "function";
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function T(n) {
|
|
52
52
|
return n && typeof n.next == "function";
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
function
|
|
56
|
-
return
|
|
54
|
+
const y = /^[A-Za-z_$]+[\w$]*$/;
|
|
55
|
+
function d(n) {
|
|
56
|
+
return y.test(n);
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
function
|
|
58
|
+
const l = /(^\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*=>)/;
|
|
59
|
+
function v(n) {
|
|
60
60
|
const t = n.toString();
|
|
61
|
-
return
|
|
61
|
+
return l.test(t);
|
|
62
62
|
}
|
|
63
|
-
const
|
|
63
|
+
const A = globalThis.AsyncFunction ?? (async function() {
|
|
64
64
|
}).constructor;
|
|
65
65
|
function S(n) {
|
|
66
|
-
return n instanceof
|
|
66
|
+
return n instanceof A;
|
|
67
67
|
}
|
|
68
|
-
const
|
|
68
|
+
const p = globalThis.GeneratorFunction ?? (function* () {
|
|
69
69
|
}).constructor;
|
|
70
70
|
function q(n) {
|
|
71
|
-
return n instanceof
|
|
71
|
+
return n instanceof p;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const g = globalThis.AsyncGeneratorFunction ?? (async function* () {
|
|
74
74
|
}).constructor;
|
|
75
75
|
function x(n) {
|
|
76
|
-
return n instanceof
|
|
76
|
+
return n instanceof g;
|
|
77
77
|
}
|
|
78
|
-
const
|
|
78
|
+
const b = /(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;
|
|
79
79
|
function E(n) {
|
|
80
80
|
if (n.name) {
|
|
81
81
|
const t = n.toString();
|
|
82
|
-
return !
|
|
82
|
+
return !b.test(t);
|
|
83
83
|
}
|
|
84
84
|
return !0;
|
|
85
85
|
}
|
|
86
|
-
function G(n
|
|
87
|
-
return n
|
|
86
|
+
function G(n) {
|
|
87
|
+
return Array.isArray(n) ? n : n == null ? [] : [n];
|
|
88
|
+
}
|
|
89
|
+
function I(n) {
|
|
90
|
+
for (const [t, e] of Object.entries(n))
|
|
91
|
+
n[t] = Array.isArray(e) ? e : e == null ? [] : [e];
|
|
92
|
+
return n;
|
|
93
|
+
}
|
|
94
|
+
function N(n, t) {
|
|
95
|
+
return n instanceof Promise ? n.then((e) => t(e, !1, void 0), (e) => t(void 0, !0, e)) : t(n, !1, void 0);
|
|
88
96
|
}
|
|
89
97
|
var c = /* @__PURE__ */ ((n) => (n.equal = "equal", n.intersect = "intersect", n.intersectEqual = "intersectEqual", n))(c || {});
|
|
90
98
|
((n) => {
|
|
91
|
-
function t(
|
|
99
|
+
function t(e) {
|
|
92
100
|
let o;
|
|
93
|
-
switch (
|
|
101
|
+
switch (e) {
|
|
94
102
|
case "equal":
|
|
95
|
-
o = (
|
|
103
|
+
o = (r, u) => r === u;
|
|
96
104
|
case "intersect":
|
|
97
|
-
o = (
|
|
105
|
+
o = (r, u) => r & u;
|
|
98
106
|
default:
|
|
99
|
-
o = (
|
|
107
|
+
o = (r, u) => (r & u) === r;
|
|
100
108
|
}
|
|
101
109
|
return o;
|
|
102
110
|
}
|
|
@@ -104,22 +112,24 @@ var c = /* @__PURE__ */ ((n) => (n.equal = "equal", n.intersect = "intersect", n
|
|
|
104
112
|
})(c || (c = {}));
|
|
105
113
|
export {
|
|
106
114
|
c as BitFlagEqualTestType,
|
|
107
|
-
|
|
115
|
+
G as formatAsArray,
|
|
116
|
+
I as formatMemberAsArray,
|
|
117
|
+
h as getExactTypeNameOf,
|
|
108
118
|
a as getExactTypeOf,
|
|
109
119
|
s as getNameOfType,
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
m as getTypeByName,
|
|
121
|
+
F as getTypeNameOf,
|
|
112
122
|
i as getTypeOf,
|
|
113
123
|
E as isAnonymousFunction,
|
|
114
124
|
$ as isArrayLike,
|
|
115
|
-
|
|
125
|
+
v as isArrowFunction,
|
|
116
126
|
S as isAsyncFunction,
|
|
117
127
|
x as isAsyncGeneratorFunction,
|
|
118
128
|
w as isBaseType,
|
|
119
129
|
q as isGeneratorFunction,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
d as isIdentifier,
|
|
131
|
+
O as isIterable,
|
|
132
|
+
T as isIterator,
|
|
123
133
|
f as isObject,
|
|
124
|
-
|
|
134
|
+
N as waitAsyncable
|
|
125
135
|
};
|
package/dist/type-tls.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(t=typeof globalThis<"u"?globalThis:t||self,i(t.TypeTls={}))})(this,function(t){"use strict";function i(n){var e=typeof n;return n&&(e==="object"||e==="function")}function s(n){var e=n;return n!=null&&(e=n.constructor,e==null&&(e=typeof n)),e}function f(n){switch(n){case void 0:return"undefined";case null:return"null"}let e=typeof n;switch(e){case"function":return n.name;case"string":return n;default:return e}}function y(n){return globalThis[n]}function l(n){let e=s(n);return f(e)}function a(n){return n==null||i(n)?s(n):typeof n}function
|
|
1
|
+
(function(t,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(t=typeof globalThis<"u"?globalThis:t||self,i(t.TypeTls={}))})(this,function(t){"use strict";function i(n){var e=typeof n;return n&&(e==="object"||e==="function")}function s(n){var e=n;return n!=null&&(e=n.constructor,e==null&&(e=typeof n)),e}function f(n){switch(n){case void 0:return"undefined";case null:return"null"}let e=typeof n;switch(e){case"function":return n.name;case"string":return n;default:return e}}function y(n){return globalThis[n]}function l(n){let e=s(n);return f(e)}function a(n){return n==null||i(n)?s(n):typeof n}function A(n){var e=a(n);return f(e)}function g(n){var e=typeof n;return n==null||e!=="object"&&e!=="function"}function T(n){let e=n&&n.length;return Number.isInteger(n.length)&&e>=0}function m(n){return n&&typeof n[Symbol.iterator]=="function"}function b(n){return n&&typeof n.next=="function"}const F=/^[A-Za-z_$]+[\w$]*$/;function d(n){return F.test(n)}const O=/(^\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 h(n){const e=n.toString();return O.test(e)}const p=globalThis.AsyncFunction??(async function(){}).constructor;function w(n){return n instanceof p}const E=globalThis.GeneratorFunction??(function*(){}).constructor;function $(n){return n instanceof E}const N=globalThis.AsyncGeneratorFunction??(async function*(){}).constructor;function S(n){return n instanceof N}const q=/(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;function I(n){if(n.name){const e=n.toString();return!q.test(e)}return!0}function j(n){return Array.isArray(n)?n:n==null?[]:[n]}function v(n){for(const[e,r]of Object.entries(n))n[e]=Array.isArray(r)?r:r==null?[]:[r];return n}function G(n,e){return n instanceof Promise?n.then(r=>e(r,!1,void 0),r=>e(void 0,!0,r)):e(n,!1,void 0)}t.BitFlagEqualTestType=(n=>(n.equal="equal",n.intersect="intersect",n.intersectEqual="intersectEqual",n))(t.BitFlagEqualTestType||{}),(n=>{function e(r){let c;switch(r){case"equal":c=(u,o)=>u===o;case"intersect":c=(u,o)=>u&o;default:c=(u,o)=>(u&o)===u}return c}n.getEqualFun=e})(t.BitFlagEqualTestType||(t.BitFlagEqualTestType={})),t.formatAsArray=j,t.formatMemberAsArray=v,t.getExactTypeNameOf=A,t.getExactTypeOf=a,t.getNameOfType=f,t.getTypeByName=y,t.getTypeNameOf=l,t.getTypeOf=s,t.isAnonymousFunction=I,t.isArrayLike=T,t.isArrowFunction=h,t.isAsyncFunction=w,t.isAsyncGeneratorFunction=S,t.isBaseType=g,t.isGeneratorFunction=$,t.isIdentifier=d,t.isIterable=m,t.isIterator=b,t.isObject=i,t.waitAsyncable=G,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
package/doc/api/type-tls.md
CHANGED
|
@@ -45,6 +45,28 @@ Description
|
|
|
45
45
|
</th></tr></thead>
|
|
46
46
|
<tbody><tr><td>
|
|
47
47
|
|
|
48
|
+
[formatAsArray(value)](./type-tls.formatasarray.md)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
</td><td>
|
|
52
|
+
|
|
53
|
+
格式化为数组格式
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
</td></tr>
|
|
57
|
+
<tr><td>
|
|
58
|
+
|
|
59
|
+
[formatMemberAsArray(data)](./type-tls.formatmemberasarray.md)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
</td><td>
|
|
63
|
+
|
|
64
|
+
格式化对象成员为数组格式
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
</td></tr>
|
|
68
|
+
<tr><td>
|
|
69
|
+
|
|
48
70
|
[getExactTypeNameOf(inst)](./type-tls.getexacttypenameof.md)
|
|
49
71
|
|
|
50
72
|
|