type-tls 3.2.2 → 3.5.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/base.d.ts CHANGED
@@ -259,3 +259,29 @@ export type ReplaceNull<SourType, NewType> = Replace<SourType, null, NewType>;
259
259
  * 可将源类型 SourType 中的代表空的类型 void | undefined | null 替换为 新的类型 NewType
260
260
  */
261
261
  export type ReplaceVoid<SourType, NewType> = Replace<SourType, void | undefined | null, NewType>;
262
+ /**
263
+ * 判断值是否为基本类型的空值值
264
+ * @remarks
265
+ * 基本类型的空值值包括:null、undefined、空字符串、仅包含空格的字符串
266
+ * @param value
267
+ * @returns
268
+ */
269
+ export declare function isEmptyValue_Base(value: any): boolean;
270
+ /**
271
+ * 判断值是否为对象类型的空值值
272
+ * @remarks
273
+ * 对象类型的空值值包括:空数组、空 Map、空 Set、自身没有键的对象
274
+ * @param value
275
+ * @returns
276
+ */
277
+ export declare function isEmptyObject(value: any): boolean;
278
+ /**
279
+ * 判断值是否为空值
280
+ * @remarks
281
+ * 空值包括
282
+ * 基本类型:null、undefined、空字符串、仅包含空格的字符串
283
+ * 对象类型:空数组、空 Map、空 Set、自身没有键的对象
284
+ * @param value
285
+ * @returns
286
+ */
287
+ export declare function isEmptyValue(value: any): boolean;
package/dist/index.d.ts CHANGED
@@ -4,3 +4,5 @@ export * from './member';
4
4
  export * from './async';
5
5
  export * from './buffer';
6
6
  export * from "./other";
7
+ export * from './vector';
8
+ export * from './size';
package/dist/size.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 二维尺寸
3
+ */
4
+ export interface Size2 {
5
+ width: number;
6
+ height: number;
7
+ }
8
+ /**
9
+ * 三维尺寸
10
+ */
11
+ export interface Size3 extends Size2 {
12
+ depth: number;
13
+ }
@@ -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 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}({});
1
+ var TypeTls=function(e){"use strict";function s(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 g(n){return globalThis[n]}function m(n){let t=o(n);return f(t)}function a(n){return n==null||s(n)?o(n):typeof n}function b(n){var t=a(n);return f(t)}function T(n){var t=typeof n;return n==null||t!=="object"&&t!=="function"}function y(n){let t=n&&n.length;return Number.isInteger(n.length)&&t>=0}function F(n){return n&&typeof n[Symbol.iterator]=="function"}function O(n){return n&&typeof n.next=="function"}function l(n){return n==null?!0:typeof n=="string"?n===""||n.trim()==="":!1}function A(n){return n==null?!0:typeof n!="object"?!1:y(n)?n.length===0:n instanceof Map||n instanceof Set?n.size===0:Reflect.ownKeys(n).length===0}function E(n){return typeof n=="object"?A(n):l(n)}const w=/^[A-Za-z_$]+[\w$]*$/;function h(n){return w.test(n)}const p=/(^\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 p.test(t)}const j=globalThis.AsyncFunction??(async function(){}).constructor;function S(n){return n instanceof j}const $=globalThis.GeneratorFunction??(function*(){}).constructor;function N(n){return n instanceof $}const q=globalThis.AsyncGeneratorFunction??(async function*(){}).constructor;function I(n){return n instanceof q}const G=/(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;function B(n){if(n.name){const t=n.toString();return!G.test(t)}return!0}function _(n){return Array.isArray(n)?n:n==null?[]:[n]}function z(n){for(const[t,r]of Object.entries(n))n[t]=Array.isArray(r)?r:r==null?[]:[r];return n}function Z(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=(i,u)=>i===u;case"intersect":c=(i,u)=>i&u;default:c=(i,u)=>(i&u)===i}return c}n.getEqualFun=t})(e.BitFlagEqualTestType||(e.BitFlagEqualTestType={})),e.formatAsArray=_,e.formatMemberAsArray=z,e.getExactTypeNameOf=b,e.getExactTypeOf=a,e.getNameOfType=f,e.getTypeByName=g,e.getTypeNameOf=m,e.getTypeOf=o,e.isAnonymousFunction=B,e.isArrayLike=y,e.isArrowFunction=d,e.isAsyncFunction=S,e.isAsyncGeneratorFunction=I,e.isBaseType=T,e.isEmptyObject=A,e.isEmptyValue=E,e.isEmptyValue_Base=l,e.isGeneratorFunction=N,e.isIdentifier=h,e.isIterable=F,e.isIterator=O,e.isObject=s,e.waitAsyncable=Z,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
package/dist/type-tls.js CHANGED
@@ -2,7 +2,7 @@ function f(n) {
2
2
  var t = typeof n;
3
3
  return n && (t === "object" || t === "function");
4
4
  }
5
- function i(n) {
5
+ function c(n) {
6
6
  var t = n;
7
7
  return n != null && (t = n.constructor, t == null && (t = typeof n)), t;
8
8
  }
@@ -23,113 +23,125 @@ function s(n) {
23
23
  return t;
24
24
  }
25
25
  }
26
- function m(n) {
26
+ function w(n) {
27
27
  return globalThis[n];
28
28
  }
29
- function F(n) {
30
- let t = i(n);
29
+ function $(n) {
30
+ let t = c(n);
31
31
  return s(t);
32
32
  }
33
- function a(n) {
34
- return n == null || f(n) ? i(n) : typeof n;
33
+ function y(n) {
34
+ return n == null || f(n) ? c(n) : typeof n;
35
35
  }
36
- function h(n) {
37
- var t = a(n);
36
+ function O(n) {
37
+ var t = y(n);
38
38
  return s(t);
39
39
  }
40
- function w(n) {
40
+ function E(n) {
41
41
  var t = typeof n;
42
42
  return n == null || t !== "object" && t !== "function";
43
43
  }
44
- function $(n) {
44
+ function a(n) {
45
45
  let t = n && n.length;
46
46
  return Number.isInteger(n.length) && t >= 0;
47
47
  }
48
- function O(n) {
48
+ function S(n) {
49
49
  return n && typeof n[Symbol.iterator] == "function";
50
50
  }
51
51
  function T(n) {
52
52
  return n && typeof n.next == "function";
53
53
  }
54
- const y = /^[A-Za-z_$]+[\w$]*$/;
54
+ function l(n) {
55
+ return n == null ? !0 : typeof n == "string" ? n === "" || n.trim() === "" : !1;
56
+ }
57
+ function p(n) {
58
+ return n == null ? !0 : typeof n != "object" ? !1 : a(n) ? n.length === 0 : n instanceof Map || n instanceof Set ? n.size === 0 : Reflect.ownKeys(n).length === 0;
59
+ }
55
60
  function d(n) {
56
- return y.test(n);
61
+ return typeof n == "object" ? p(n) : l(n);
57
62
  }
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) {
63
+ const A = /^[A-Za-z_$]+[\w$]*$/;
64
+ function j(n) {
65
+ return A.test(n);
66
+ }
67
+ const g = /(^\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*=>)/;
68
+ function q(n) {
60
69
  const t = n.toString();
61
- return l.test(t);
70
+ return g.test(t);
62
71
  }
63
- const A = globalThis.AsyncFunction ?? (async function() {
72
+ const b = globalThis.AsyncFunction ?? (async function() {
64
73
  }).constructor;
65
- function S(n) {
66
- return n instanceof A;
74
+ function x(n) {
75
+ return n instanceof b;
67
76
  }
68
- const p = globalThis.GeneratorFunction ?? (function* () {
77
+ const m = globalThis.GeneratorFunction ?? (function* () {
69
78
  }).constructor;
70
- function q(n) {
71
- return n instanceof p;
79
+ function z(n) {
80
+ return n instanceof m;
72
81
  }
73
- const g = globalThis.AsyncGeneratorFunction ?? (async function* () {
82
+ const F = globalThis.AsyncGeneratorFunction ?? (async function* () {
74
83
  }).constructor;
75
- function x(n) {
76
- return n instanceof g;
84
+ function G(n) {
85
+ return n instanceof F;
77
86
  }
78
- const b = /(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;
79
- function E(n) {
87
+ const h = /(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;
88
+ function I(n) {
80
89
  if (n.name) {
81
90
  const t = n.toString();
82
- return !b.test(t);
91
+ return !h.test(t);
83
92
  }
84
93
  return !0;
85
94
  }
86
- function G(n) {
95
+ function N(n) {
87
96
  return Array.isArray(n) ? n : n == null ? [] : [n];
88
97
  }
89
- function I(n) {
90
- for (const [t, e] of Object.entries(n))
91
- n[t] = Array.isArray(e) ? e : e == null ? [] : [e];
98
+ function _(n) {
99
+ for (const [t, r] of Object.entries(n))
100
+ n[t] = Array.isArray(r) ? r : r == null ? [] : [r];
92
101
  return n;
93
102
  }
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);
103
+ function Z(n, t) {
104
+ return n instanceof Promise ? n.then((r) => t(r, !1, void 0), (r) => t(void 0, !0, r)) : t(n, !1, void 0);
96
105
  }
97
- var c = /* @__PURE__ */ ((n) => (n.equal = "equal", n.intersect = "intersect", n.intersectEqual = "intersectEqual", n))(c || {});
106
+ var i = /* @__PURE__ */ ((n) => (n.equal = "equal", n.intersect = "intersect", n.intersectEqual = "intersectEqual", n))(i || {});
98
107
  ((n) => {
99
- function t(e) {
100
- let o;
101
- switch (e) {
108
+ function t(r) {
109
+ let u;
110
+ switch (r) {
102
111
  case "equal":
103
- o = (r, u) => r === u;
112
+ u = (e, o) => e === o;
104
113
  case "intersect":
105
- o = (r, u) => r & u;
114
+ u = (e, o) => e & o;
106
115
  default:
107
- o = (r, u) => (r & u) === r;
116
+ u = (e, o) => (e & o) === e;
108
117
  }
109
- return o;
118
+ return u;
110
119
  }
111
120
  n.getEqualFun = t;
112
- })(c || (c = {}));
121
+ })(i || (i = {}));
113
122
  export {
114
- c as BitFlagEqualTestType,
115
- G as formatAsArray,
116
- I as formatMemberAsArray,
117
- h as getExactTypeNameOf,
118
- a as getExactTypeOf,
123
+ i as BitFlagEqualTestType,
124
+ N as formatAsArray,
125
+ _ as formatMemberAsArray,
126
+ O as getExactTypeNameOf,
127
+ y as getExactTypeOf,
119
128
  s as getNameOfType,
120
- m as getTypeByName,
121
- F as getTypeNameOf,
122
- i as getTypeOf,
123
- E as isAnonymousFunction,
124
- $ as isArrayLike,
125
- v as isArrowFunction,
126
- S as isAsyncFunction,
127
- x as isAsyncGeneratorFunction,
128
- w as isBaseType,
129
- q as isGeneratorFunction,
130
- d as isIdentifier,
131
- O as isIterable,
129
+ w as getTypeByName,
130
+ $ as getTypeNameOf,
131
+ c as getTypeOf,
132
+ I as isAnonymousFunction,
133
+ a as isArrayLike,
134
+ q as isArrowFunction,
135
+ x as isAsyncFunction,
136
+ G as isAsyncGeneratorFunction,
137
+ E as isBaseType,
138
+ p as isEmptyObject,
139
+ d as isEmptyValue,
140
+ l as isEmptyValue_Base,
141
+ z as isGeneratorFunction,
142
+ j as isIdentifier,
143
+ S as isIterable,
132
144
  T as isIterator,
133
145
  f as isObject,
134
- N as waitAsyncable
146
+ Z as waitAsyncable
135
147
  };
@@ -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 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"})});
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 f(n){var e=n;return n!=null&&(e=n.constructor,e==null&&(e=typeof n)),e}function s(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 m(n){return globalThis[n]}function g(n){let e=f(n);return s(e)}function a(n){return n==null||i(n)?f(n):typeof n}function T(n){var e=a(n);return s(e)}function b(n){var e=typeof n;return n==null||e!=="object"&&e!=="function"}function y(n){let e=n&&n.length;return Number.isInteger(n.length)&&e>=0}function F(n){return n&&typeof n[Symbol.iterator]=="function"}function d(n){return n&&typeof n.next=="function"}function l(n){return n==null?!0:typeof n=="string"?n===""||n.trim()==="":!1}function A(n){return n==null?!0:typeof n!="object"?!1:y(n)?n.length===0:n instanceof Map||n instanceof Set?n.size===0:Reflect.ownKeys(n).length===0}function p(n){return typeof n=="object"?A(n):l(n)}const O=/^[A-Za-z_$]+[\w$]*$/;function E(n){return O.test(n)}const h=/(^\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 w(n){const e=n.toString();return h.test(e)}const j=globalThis.AsyncFunction??(async function(){}).constructor;function S(n){return n instanceof j}const $=globalThis.GeneratorFunction??(function*(){}).constructor;function N(n){return n instanceof $}const q=globalThis.AsyncGeneratorFunction??(async function*(){}).constructor;function I(n){return n instanceof q}const G=/(^\s*(async\s+)?function\s*(\s|\*)\s*)[A-Za-z_$]+[\w$]*(\s*\()/;function B(n){if(n.name){const e=n.toString();return!G.test(e)}return!0}function _(n){return Array.isArray(n)?n:n==null?[]:[n]}function z(n){for(const[e,r]of Object.entries(n))n[e]=Array.isArray(r)?r:r==null?[]:[r];return n}function Z(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 o;switch(r){case"equal":o=(u,c)=>u===c;case"intersect":o=(u,c)=>u&c;default:o=(u,c)=>(u&c)===u}return o}n.getEqualFun=e})(t.BitFlagEqualTestType||(t.BitFlagEqualTestType={})),t.formatAsArray=_,t.formatMemberAsArray=z,t.getExactTypeNameOf=T,t.getExactTypeOf=a,t.getNameOfType=s,t.getTypeByName=m,t.getTypeNameOf=g,t.getTypeOf=f,t.isAnonymousFunction=B,t.isArrayLike=y,t.isArrowFunction=w,t.isAsyncFunction=S,t.isAsyncGeneratorFunction=I,t.isBaseType=b,t.isEmptyObject=A,t.isEmptyValue=p,t.isEmptyValue_Base=l,t.isGeneratorFunction=N,t.isIdentifier=E,t.isIterable=F,t.isIterator=d,t.isObject=i,t.waitAsyncable=Z,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 二维向量
3
+ */
4
+ export interface IVector2 {
5
+ x: number;
6
+ y: number;
7
+ }
8
+ /**
9
+ * 三维向量
10
+ */
11
+ export interface IVector3 extends IVector2 {
12
+ z: number;
13
+ }
14
+ /**
15
+ * 四维向量
16
+ */
17
+ export interface IVector4 extends IVector3 {
18
+ w: number;
19
+ }
20
+ /**
21
+ * 向量
22
+ */
23
+ export type IVector = IVector2 | IVector3 | IVector4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-tls",
3
- "version": "3.2.2",
3
+ "version": "3.5.0",
4
4
  "description": "type-tls 封装了与类型相关的工具,比如:获取数据的类型 或 类型名字、判断数据的类型 等",
5
5
  "main": "./dist/type-tls.umd.cjs",
6
6
  "module": "./dist/type-tls.js",
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.7"
9
- }
10
- ]
11
- }
@@ -1,465 +0,0 @@
1
- /**
2
- * 表示任意的函数类型
3
- */
4
- export declare type AnyFunction = (...args: any) => any;
5
-
6
- /**
7
- * 获取数组元素的类型
8
- * @typeParam Arr 数组
9
- */
10
- export declare type ArrayItemType<Arr> = Arr extends (infer Item)[] ? Item : never;
11
-
12
- /**
13
- * 位标志相等测试
14
- */
15
- export declare enum BitFlagEqualTestType {
16
- /**
17
- * 相等:A === B
18
- */
19
- equal = "equal",// "相等"
20
- /**
21
- * 相交:A & B
22
- */
23
- intersect = "intersect",// "相交"
24
- /**
25
- * 交等:A & B === A
26
- */
27
- intersectEqual = "intersectEqual"
28
- }
29
-
30
- export declare namespace BitFlagEqualTestType {
31
- /**
32
- * 获取 位标志相等测试的函数
33
- * @param testType 默认 intersectEqual
34
- * @returns
35
- */
36
- export function getEqualFun(testType?: BitFlagEqualTestType | null): (a: number, b: number) => number | boolean;
37
- }
38
-
39
- /**
40
- * 精确类型
41
- *
42
- * @remarks
43
- * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
44
- * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
45
- * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
46
- * 但,对于 undefined 和 null 会返回其自身值(即 undefined 和 null)作为类型值
47
- *
48
- * 各种类型的值 与 该方法的返回值 的映射如下:
49
- * ```
50
- * undefined :undefined
51
- * null : null
52
- * string : "string"
53
- * number : "number"
54
- * bigint : "bigint"
55
- * boolean : "boolean"
56
- * symbol : "symbol"
57
- * function : Function
58
- * 没有原型的对象(如:通过 `Object.create(null)` 创建的对象) : "object"
59
- * 其它任何类型的实例 : 返回该实例的构造函数
60
- * ```
61
- */
62
- export declare type ExactType = LooseType | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
63
-
64
- /**
65
- * 精确类型的字符串表示
66
- *
67
- * @remarks
68
- * 在精准类型中认为 JavaScript 的原始类型(非对象类型) 与 其对应的 包装类型(类类型)是不同的类型,即:
69
- * number 和 Number、string 和 String、boolean 和 Boolean 等 是不同的类型;
70
- * 对于原始类型,返回的结果 会与 typeof 返回的结果一样;
71
- * 但,对于 null 会返回 "null"
72
- *
73
- * 各种类型的值 与 该方法的返回值 的映射如下:
74
- * ```
75
- * undefined :"undefined"
76
- * null : "null"
77
- * function : "Function"
78
- * string : "string"
79
- * number : "number"
80
- * bigint : "bigint"
81
- * boolean : "boolean"
82
- * symbol : "symbol"
83
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
84
- * 其它任何类型的实例 : 返回该实例的构造函数的名字
85
- * ```
86
- */
87
- export declare type ExactTypeName = LooseTypeName | Exclude<TypeOfReturnType, "undefined" | "function" | "object">;
88
-
89
- /**
90
- * 格式化为数组格式
91
- * @remarks
92
- * 如果 ItemOrArray 是数组,则保持不变
93
- * 如果 ItemOrArray 不是数组,则转为数组类型 ItemOrArray[]
94
- */
95
- export declare type FormatAsArray<ItemOrArray> = ItemOrArray extends any[] ? ItemOrArray : ItemOrArray[];
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
-
107
- /**
108
- * 格式化对象成员为数组格式
109
- * @remarks
110
- * 如果 成员 是数组,则保持不变
111
- * 如果 成员 不是数组,则转为数组类型
112
- */
113
- export declare type FormatMemberAsArray<D> = {
114
- [K in keyof D]: FormatAsArray<D[K]>;
115
- };
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
-
127
- /**
128
- * 获取 inst 的精确类型的字符串表示
129
- * @param inst
130
- * @returns inst 的类型字符串
131
- */
132
- export declare function getExactTypeNameOf(inst: any): ExactTypeName;
133
-
134
- /**
135
- * 获取 inst 的精确类型
136
- * @param inst
137
- * @returns inst 的类型
138
- */
139
- export declare function getExactTypeOf(inst: any): ExactType;
140
-
141
- /**
142
- * 获取 类型的字符串表示
143
- *
144
- * @param t - 一个 ExactType 类型的值
145
- * @return t 的字符串表示的类型
146
- */
147
- export declare function getNameOfType(t: ExactType): ExactTypeName;
148
-
149
- /**
150
- * 根据类型的名字获取其对应的类
151
- * @param typeName - 类型的名字
152
- */
153
- export declare function getTypeByName(typeName: string): Function | undefined;
154
-
155
- /**
156
- * 获取 inst 的类型字符串
157
- *
158
- * @remarks
159
- * 注意:
160
- * 本方法返回的结果如下:
161
- * undefined :"undefined"
162
- * null : "null"
163
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
164
- * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数 的函数名字
165
- *
166
- * @param inst
167
- * @returns inst 的类型字符串
168
- */
169
- export declare function getTypeNameOf(inst: any): LooseTypeName;
170
-
171
- /**
172
- * 获取 inst 的宽松类型
173
- *
174
- * @remarks
175
- * 注意:
176
- * 本方法返回的结果如下:
177
- * ```
178
- * undefined :undefined
179
- * null : null
180
- * function : Function
181
- * 没有原型的对象(如:通过 Object.create(null) 创建的对象) : "object"
182
- * 其它任何类型的实例 : 返回该实例的构造函数 或 包装对象的构造函数
183
- * ```
184
- *
185
- *
186
- * @param inst
187
- * @returns inst 的类型
188
- */
189
- export declare function getTypeOf(inst: any): LooseType;
190
-
191
- /**
192
- * 判断是否是匿名函数
193
- *
194
- * @remarks
195
- * 判断函数在被定义时是否是通过匿名函数来定义的。
196
- * 匿名函数是指声明函数时没有写名字的函数。
197
- * 注意:即使是匿名函数,函数对象上的 name 属性也可能是有值的,因为 js解析器 会自动将 函数表达式函数变量的名字作为匿名函数的名字,如下:
198
- * ```ts
199
- * var funName = function(){};
200
- * ```
201
- * 其中的匿名函数对象的 name 属性的值会是 `funName`
202
- *
203
- * 如果 函数对象上的 name 属性的值为 `""`,函数一定是匿名函数。
204
- */
205
- export declare function isAnonymousFunction(fun: Function): boolean;
206
-
207
- /**
208
- * 判断 target 是否为 类数组对象
209
- * @param target - 目标
210
- * @returns
211
- */
212
- export declare function isArrayLike(target: any): boolean;
213
-
214
- /**
215
- * 判断函数是否是箭头函数
216
- * @param fun - 被判断的函数
217
- */
218
- export declare function isArrowFunction(fun: Function): boolean;
219
-
220
- /**
221
- * 判断函数是否是 async 异步函数
222
- * @remarks
223
- * 异步函数 不包含 异步生成器函数 AsyncGeneratorFunction
224
- * @param fun - 被判断的函数
225
- */
226
- export declare function isAsyncFunction(fun: Function): boolean;
227
-
228
- /**
229
- * 判断函数是否是异步生成器函数
230
- * @param fun - 被判断的函数
231
- */
232
- export declare function isAsyncGeneratorFunction(fun: Function): boolean;
233
-
234
- /**
235
- * 判断 data 是否是 基本类型
236
- * @remarks
237
- * 基本类型 是指 那些不是 对象类型的类型,即,除了 object 和 function 类型以外,其它的都是基本类型,null 也算怎是 基本类型
238
- * @param data - 任意类型的值
239
- */
240
- export declare function isBaseType(data: any): boolean;
241
-
242
- /**
243
- * 判断函数是否是生成器函数
244
- *
245
- * @remarks
246
- * 生成器函数 不包含 异步生成器函数 AsyncGeneratorFunction
247
- * @param fun - 被判断的函数
248
- */
249
- export declare function isGeneratorFunction(fun: Function): boolean;
250
-
251
- /**
252
- * 判断 code 是否是有校的 js 标识符
253
- * @param code - 标识符的字符串
254
- */
255
- export declare function isIdentifier(code: string): boolean;
256
-
257
- /**
258
- * 判断 目标 是否是可迭代的对象,即 实现了 可迭代协议
259
- * @param target - 目标
260
- */
261
- export declare function isIterable(target: any): boolean;
262
-
263
- /**
264
- * 判断 目标 是否是迭代器,即 实现了 迭代器协议
265
- * @param target - 目标
266
- */
267
- export declare function isIterator(target: any): boolean;
268
-
269
- /**
270
- * 判断目标是否是对象类型
271
- *
272
- * @remarks
273
- * 仅通过 target instanceof Object 判断是不行的,因为 对于 Object.create(null) 创建的对象 通过 ` Object.create(null) instanceof Object ` 来判断 返回的是 false
274
- * 即:通过 Object.create(null) 创建的对象是不被 instanceof 认为是继续于 Object 的
275
- *
276
- * typeof null 也返回 "object"
277
- *
278
- * @param target : any 目标对象
279
- */
280
- export declare function isObject(target: any): boolean;
281
-
282
- /**
283
- * 获取值类型包含指定类型的所有 key
284
- *
285
- * @typeParam Target - 目标对象
286
- * @typeParam Value - 要获取的key的对应值应包含的类型
287
- */
288
- export declare type KeyOfContainsValue<Target, Value> = {
289
- [K in keyof Target]: Value extends Target[K] ? K : never;
290
- }[keyof Target];
291
-
292
- /**
293
- * 获取值类型不应包含指定类型的所有 key
294
- *
295
- * @typeParam Target - 目标对象
296
- * @typeParam Value - 不应包含的值的类型
297
- */
298
- export declare type KeyOfNonContainsValue<Target, Value> = {
299
- [K in keyof Target]: Value extends Target[K] ? never : K;
300
- }[keyof Target];
301
-
302
- /**
303
- * 获取值类型不是指定类型的所有 key
304
- *
305
- * @typeParam Target - 目标对象
306
- * @typeParam Value - 被排除的值的类型
307
- */
308
- export declare type KeyOfNonValue<Target, Value> = {
309
- [K in keyof Target]: Target[K] extends Value ? never : K;
310
- }[keyof Target];
311
-
312
- /**
313
- * 获取值类型为指定类型的所有 key
314
- *
315
- * @typeParam Target - 目标对象
316
- * @typeParam Value - 要获取的key的对应值的类型
317
- */
318
- export declare type KeyOfValue<Target, Value> = {
319
- [K in keyof Target]: Target[K] extends Value ? K : never;
320
- }[keyof Target];
321
-
322
- /**
323
- * 宽松的类型
324
- */
325
- export declare type LooseType = undefined | null | Function | "object";
326
-
327
- /**
328
- * 宽松类型的字符串表示
329
- */
330
- export declare type LooseTypeName = "undefined" | "null" | "Function" | "object" | string;
331
-
332
- /**
333
- * 获取对象的方法的某个参数的类型
334
- *
335
- * @typeParam Obj - 对象
336
- * @typeParam Method - 对象方法的名字
337
- * @typeParam ParamIndex - 参数的索引个数
338
- */
339
- export declare type MethodParams<Obj, Method extends keyof Obj, ParamIndex extends number> = Obj[Method] extends AnyFunction ? Parameters<Obj[Method]>[ParamIndex] : never;
340
-
341
- /**
342
- * 获取对象的方法的返回的类型
343
- *
344
- * @typeParam Obj - 对象
345
- * @typeParam Method - 对象方法的名字
346
- */
347
- export declare type MethodReturnType<Obj, Method extends keyof Obj> = Obj[Method] extends AnyFunction ? ReturnType<Obj[Method]> : never;
348
-
349
- /**
350
- * 将某个类型变为可选的类型
351
- */
352
- export declare type Optional<T> = T | null | undefined;
353
-
354
- /**
355
- * 可选的布尔类型
356
- */
357
- export declare type OptionalBoolean = Optional<boolean>;
358
-
359
- /**
360
- * 从 Target 中挑选出那些成员值的类型包含 Value 类型的成员
361
- */
362
- export declare type PickContainsValue<Target, Value> = {
363
- [P in KeyOfContainsValue<Target, Value>]: Target[P];
364
- };
365
-
366
- /**
367
- * 从 Target 中挑选出方法
368
- */
369
- export declare type PickMethod<Target> = PickValue<Target, AnyFunction>;
370
-
371
- /**
372
- * 从 Target 中挑选出那些成员值的类型不包含 Value 类型的成员
373
- */
374
- export declare type PickNonContainsValue<Target, Value> = {
375
- [P in KeyOfNonContainsValue<Target, Value>]: Target[P];
376
- };
377
-
378
- /**
379
- * 从 Target 中挑选出那些成员值不是 Value 的类型的成员
380
- */
381
- export declare type PickNonValue<Target, Value> = {
382
- [P in KeyOfNonValue<Target, Value>]: Target[P];
383
- };
384
-
385
- /**
386
- * 从 Target 中挑选出属性
387
- */
388
- export declare type PickProperty<Target> = PickNonValue<Target, AnyFunction>;
389
-
390
- /**
391
- * 从 T 中挑选出那些成员值为 Value 的类型的成员
392
- */
393
- export declare type PickValue<Target, Value> = {
394
- [P in KeyOfValue<Target, Value>]: Target[P];
395
- };
396
-
397
- /**
398
- * 可将源类型 SourType 中的 类型 MatchType 替换为 新的类型 NewType
399
- */
400
- export declare type Replace<SourType, MatchType, NewType> = SourType extends MatchType ? NewType : SourType;
401
-
402
- /**
403
- * 可将源类型 SourType 中的 null 替换为 新的类型 NewType
404
- */
405
- export declare type ReplaceNull<SourType, NewType> = Replace<SourType, null, NewType>;
406
-
407
- /**
408
- * 可将源类型 SourType 中的 undefined 替换为 新的类型 NewType
409
- */
410
- export declare type ReplaceUndefined<SourType, NewType> = Replace<SourType, undefined, NewType>;
411
-
412
- /**
413
- * 可将源类型 SourType 中的代表空的类型 void | undefined | null 替换为 新的类型 NewType
414
- */
415
- export declare type ReplaceVoid<SourType, NewType> = Replace<SourType, void | undefined | null, NewType>;
416
-
417
- /**
418
- * 获取 Promise 解决的类型的值
419
- * @remarks
420
- * 对于非 Promise 类型的值,返回原类型本身
421
- */
422
- export declare type ResolveData<P> = P extends Promise<infer D> ? D : P;
423
-
424
- /**
425
- * 将 T 及其对象成员属性值都改为 Partial 类型
426
- * @remarks
427
- * 比 Partial 又深入的一层
428
- */
429
- export declare type TwoLayerPartial<T> = {
430
- [P in keyof T]?: Partial<T[P]>;
431
- };
432
-
433
- export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array | Float32Array | Float64Array;
434
-
435
- /**
436
- * typeof 的返回类型
437
- */
438
- export declare type TypeOfReturnType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
439
-
440
- /**
441
- * 等待可异步的结果
442
- *
443
- * @remarks
444
- * 当 asyncable 为同步值时,会同步调用 callback。
445
- * 当 asyncable 为异步值时,会等待 asyncable 解决后再调用 callback。
446
- *
447
- * @param asyncable - 可异步的结果
448
- * @param callback
449
- * @returns
450
- */
451
- export declare function waitAsyncable<Result, Return>(asyncable: Result, callback: WaitAsyncableCallback<Result, Return>): WaitAsyncableReturn<Result, Return>;
452
-
453
- /**
454
- * waitAsyncable 的回调函数的类型
455
- * @param result - 同步的结果
456
- * @param rejected - 异步是否被拒绝
457
- */
458
- export declare type WaitAsyncableCallback<Result, Return> = (result: ResolveData<Result> | undefined, rejected: boolean, error: any) => Return;
459
-
460
- /**
461
- * waitAsyncable 的返回值的类型
462
- */
463
- export declare type WaitAsyncableReturn<Result, Return> = Return extends Promise<any> ? Return : (Result extends Promise<any> ? Promise<Return> : Return);
464
-
465
- export { }