@lntvow/utils 1.8.7 → 1.8.9

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function p(t){return t>10?p(10)+p(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const a=Object.prototype.toString,f=t=>a.call(t),w=(...t)=>console.log(`%c ${t[0]}`,"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",t.slice(1)),E=(...t)=>console.warn(...t),C=(...t)=>console.error(...t),j=t=>f(t)==="[object Map]",$=t=>f(t)==="[object Set]",g=t=>f(t)==="[object Date]",h=t=>f(t)==="[object RegExp]",l=t=>typeof t=="function",M=t=>typeof t=="string",U=t=>typeof t=="symbol",u=t=>t!==null&&typeof t=="object",A=t=>u(t)&&l(t.then)&&l(t.catch),c=t=>t==null,x=t=>t===void 0,b=t=>t===null;function N(t){return t!=null}function R(t){return typeof t=="boolean"}const d=Array.isArray,m=(t,e)=>Object.hasOwn(t,e),D=(t,e)=>t!==e;function O(t){const e=new WeakMap;function r(n){if(g(n))return new Date(n);if(h(n))return new RegExp(n);if(u(n)){if(e.has(n))return e.get(n);let o={};if(d(n)){o=[],e.set(n,o);for(let i=0;i<n.length;i++)o[i]=r(n[i]);return o}e.set(n,o);for(const i in n)m(n,i)&&(o[i]=r(n[i]));return o}else return n}return r(t)}function S(t,e,r){return d(t)?T(t,e,r):P(t,e,r)}function P(t,e,r){const n=s(e,r);return Object.keys(t).forEach(i=>{c(e[i])?n[i]=s(t[i],r):n[i]=u(t[i])&&u(e[i])?S(t[i],e[i],r):s(e[i],r)}),n}function T(t,e,r){if(d(e)){const n=s(e,r);return n.push(...s(t,r)),n}else return s(t,r)}function s(t,e){const{isDeepClone:r=!0}=e||{};return r?O(t):t}function F(t,e=1e3){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,...n)},e)}}function L(t,e=1e3){let r=null;return function(...n){if(b(r))return r=Date.now(),t.apply(this,...n);{const o=Date.now();if(o-r>=e)return r=o,t.apply(this,...n)}}}function Z(...t){return t.reduce((e,r)=>function(...n){return r(e(...n))})}function z(...t){return t.reduce((e,r)=>function(...n){return e(r(...n))})}function _(t){return/^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[1589]))\d{8}$/.test(t)}function B(t){return/^([\w-])+@([\w-])+(.[\w-])+/.test(t)}function I(t){return/^[A-Z]+$/.test(t)}function K(t){return!c(t)&&/^[a-z]+$/.test(t)}function W(t){return/^\d+$/.test(t)}function q(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function G(t){return t===""}function H(t){return!c(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function J(t){return!c(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function Q(t){return!c(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function V(t){return/^[\dA-Z_]+$/.test(t)}function X(t){return/^[1-9]\d*$/.test(t)}function Y(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}exports.compose=Z;exports.composeRight=z;exports.debounce=F;exports.deepClone=O;exports.deepMerge=S;exports.error=C;exports.getRandomColor=y;exports.getRandomString=p;exports.hasChanged=D;exports.hasOwn=m;exports.isArray=d;exports.isBoolean=R;exports.isChineseOrEnglish=J;exports.isChineseOrEnglishOrNumber=H;exports.isDate=g;exports.isDef=N;exports.isEmail=B;exports.isEmptyString=G;exports.isFunction=l;exports.isLatitudeOrLongitude=q;exports.isLowerCase=K;exports.isMap=j;exports.isMobilePhone=_;exports.isNull=b;exports.isNumber=W;exports.isObject=u;exports.isPositiveFloat=Y;exports.isPositiveInt=X;exports.isPromise=A;exports.isRegExp=h;exports.isSet=$;exports.isString=M;exports.isSymbol=U;exports.isUndef=c;exports.isUndefined=x;exports.isUpperCase=I;exports.isUppercaseOrNumbersOrSpecial=Q;exports.isUppercaseOrNumbersOrUnderline=V;exports.log=w;exports.objectToString=a;exports.throttle=L;exports.toTypeString=f;exports.warn=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function S(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function p(n){return n>10?p(10)+p(n-10):Math.random().toString(36).padEnd(12,"0").slice(2,n+2)}const l=Object.prototype.toString,f=n=>l.call(n),w=(...n)=>console.log(`%c ${n[0]} `,"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",n.slice(1)),E=(...n)=>console.warn(...n),C=(...n)=>console.error(...n),A=n=>f(n)==="[object Map]",j=n=>f(n)==="[object Set]",g=n=>f(n)==="[object Date]",h=n=>f(n)==="[object RegExp]",a=n=>typeof n=="function",$=n=>typeof n=="string",M=n=>typeof n=="symbol",u=n=>n!==null&&typeof n=="object",U=n=>u(n)&&a(n.then)&&a(n.catch),c=n=>n==null,x=n=>n===void 0,b=n=>n===null;function N(n){return n!=null}function R(n){return typeof n=="boolean"}const d=Array.isArray,m=(n,e)=>Object.hasOwn(n,e),D=(n,e)=>n!==e;function O(n){const e=new WeakMap;function r(t){if(g(t))return new Date(t);if(h(t))return new RegExp(t);if(u(t)){if(e.has(t))return e.get(t);let o={};if(d(t)){o=[],e.set(t,o);for(let i=0;i<t.length;i++)o[i]=r(t[i]);return o}e.set(t,o);for(const i in t)m(t,i)&&(o[i]=r(t[i]));return o}else return t}return r(n)}function y(n,e,r){return d(n)?T(n,e,r):P(n,e,r)}function P(n,e,r){const t=s(e,r);return Object.keys(n).forEach(i=>{c(e[i])?t[i]=s(n[i],r):t[i]=u(n[i])&&u(e[i])?y(n[i],e[i],r):s(e[i],r)}),t}function T(n,e,r){if(d(e)){const t=s(e,r);return t.push(...s(n,r)),t}else return s(n,r)}function s(n,e){const{isDeepClone:r=!0}=e||{};return r?O(n):n}function F(n,e=1e3){let r=null;return function(...t){r&&clearTimeout(r),r=setTimeout(()=>{n.apply(this,...t)},e)}}function L(n,e=1e3){let r=null;return function(...t){if(b(r))return r=Date.now(),n.apply(this,...t);{const o=Date.now();if(o-r>=e)return r=o,n.apply(this,...t)}}}function Z(...n){return n.reduce((e,r)=>function(...t){return r(e(...t))})}function z(...n){return n.reduce((e,r)=>function(...t){return e(r(...t))})}function _(n){return/^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[1589]))\d{8}$/.test(n)}function B(n){return/^([\w-])+@([\w-])+(.[\w-])+/.test(n)}function I(n){return/^[A-Z]+$/.test(n)}function K(n){return!c(n)&&/^[a-z]+$/.test(n)}function W(n){return/^\d+$/.test(n)}function q(n){return/^-?\d{1,3}\.\d{6}$/.test(n)}function G(n){return n===""}function H(n){return!c(n)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(n)}function J(n){return!c(n)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(n)}function Q(n){return!c(n)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(n)}function V(n){return/^[\dA-Z_]+$/.test(n)}function X(n){return/^[1-9]\d*$/.test(n)}function Y(n){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(n)}function k(n){return Array.isArray(n)?n:[n]}exports.castArray=k;exports.compose=Z;exports.composeRight=z;exports.debounce=F;exports.deepClone=O;exports.deepMerge=y;exports.error=C;exports.getRandomColor=S;exports.getRandomString=p;exports.hasChanged=D;exports.hasOwn=m;exports.isArray=d;exports.isBoolean=R;exports.isChineseOrEnglish=J;exports.isChineseOrEnglishOrNumber=H;exports.isDate=g;exports.isDef=N;exports.isEmail=B;exports.isEmptyString=G;exports.isFunction=a;exports.isLatitudeOrLongitude=q;exports.isLowerCase=K;exports.isMap=A;exports.isMobilePhone=_;exports.isNull=b;exports.isNumber=W;exports.isObject=u;exports.isPositiveFloat=Y;exports.isPositiveInt=X;exports.isPromise=U;exports.isRegExp=h;exports.isSet=j;exports.isString=$;exports.isSymbol=M;exports.isUndef=c;exports.isUndefined=x;exports.isUpperCase=I;exports.isUppercaseOrNumbersOrSpecial=Q;exports.isUppercaseOrNumbersOrUnderline=V;exports.log=w;exports.objectToString=l;exports.throttle=L;exports.toTypeString=f;exports.warn=E;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export declare type AnyObj = Record<string, any>;
2
2
 
3
+ export declare function castArray<T = unknown>(target: T): (T & any[]) | T[];
4
+
3
5
  /**
4
6
  * @description compose
5
7
  * @param fns 任意函数
package/dist/index.mjs CHANGED
@@ -1,161 +1,165 @@
1
- function E() {
1
+ function A() {
2
2
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
3
3
  }
4
- function p(t) {
5
- return t > 10 ? p(10) + p(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
4
+ function p(n) {
5
+ return n > 10 ? p(10) + p(n - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, n + 2);
6
6
  }
7
- const g = Object.prototype.toString, f = (t) => g.call(t), S = (...t) => console.log(
8
- `%c ${t[0]}`,
7
+ const a = Object.prototype.toString, f = (n) => a.call(n), E = (...n) => console.log(
8
+ `%c ${n[0]} `,
9
9
  "padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
10
- t.slice(1)
11
- ), j = (...t) => console.warn(...t), x = (...t) => console.error(...t), A = (t) => f(t) === "[object Map]", C = (t) => f(t) === "[object Set]", a = (t) => f(t) === "[object Date]", h = (t) => f(t) === "[object RegExp]", l = (t) => typeof t == "function", M = (t) => typeof t == "string", D = (t) => typeof t == "symbol", u = (t) => t !== null && typeof t == "object", R = (t) => u(t) && l(t.then) && l(t.catch), c = (t) => t == null, U = (t) => t === void 0, b = (t) => t === null;
12
- function N(t) {
13
- return t != null;
10
+ n.slice(1)
11
+ ), S = (...n) => console.warn(...n), j = (...n) => console.error(...n), x = (n) => f(n) === "[object Map]", C = (n) => f(n) === "[object Set]", g = (n) => f(n) === "[object Date]", h = (n) => f(n) === "[object RegExp]", l = (n) => typeof n == "function", M = (n) => typeof n == "string", D = (n) => typeof n == "symbol", u = (n) => n !== null && typeof n == "object", R = (n) => u(n) && l(n.then) && l(n.catch), c = (n) => n == null, U = (n) => n === void 0, b = (n) => n === null;
12
+ function N(n) {
13
+ return n != null;
14
14
  }
15
- function Z(t) {
16
- return typeof t == "boolean";
15
+ function Z(n) {
16
+ return typeof n == "boolean";
17
17
  }
18
- const d = Array.isArray, m = (t, e) => Object.hasOwn(t, e), F = (t, e) => t !== e;
19
- function w(t) {
18
+ const d = Array.isArray, y = (n, e) => Object.hasOwn(n, e), F = (n, e) => n !== e;
19
+ function m(n) {
20
20
  const e = /* @__PURE__ */ new WeakMap();
21
- function r(n) {
22
- if (a(n))
23
- return new Date(n);
24
- if (h(n))
25
- return new RegExp(n);
26
- if (u(n)) {
27
- if (e.has(n))
28
- return e.get(n);
21
+ function r(t) {
22
+ if (g(t))
23
+ return new Date(t);
24
+ if (h(t))
25
+ return new RegExp(t);
26
+ if (u(t)) {
27
+ if (e.has(t))
28
+ return e.get(t);
29
29
  let i = {};
30
- if (d(n)) {
31
- i = [], e.set(n, i);
32
- for (let o = 0; o < n.length; o++)
33
- i[o] = r(n[o]);
30
+ if (d(t)) {
31
+ i = [], e.set(t, i);
32
+ for (let o = 0; o < t.length; o++)
33
+ i[o] = r(t[o]);
34
34
  return i;
35
35
  }
36
- e.set(n, i);
37
- for (const o in n)
38
- m(n, o) && (i[o] = r(n[o]));
36
+ e.set(t, i);
37
+ for (const o in t)
38
+ y(t, o) && (i[o] = r(t[o]));
39
39
  return i;
40
40
  } else
41
- return n;
41
+ return t;
42
42
  }
43
- return r(t);
43
+ return r(n);
44
44
  }
45
- function O(t, e, r) {
46
- return d(t) ? y(t, e, r) : $(t, e, r);
45
+ function w(n, e, r) {
46
+ return d(n) ? $(n, e, r) : O(n, e, r);
47
47
  }
48
- function $(t, e, r) {
49
- const n = s(e, r);
50
- return Object.keys(t).forEach((o) => {
51
- c(e[o]) ? n[o] = s(t[o], r) : n[o] = u(t[o]) && u(e[o]) ? O(t[o], e[o], r) : s(e[o], r);
52
- }), n;
48
+ function O(n, e, r) {
49
+ const t = s(e, r);
50
+ return Object.keys(n).forEach((o) => {
51
+ c(e[o]) ? t[o] = s(n[o], r) : t[o] = u(n[o]) && u(e[o]) ? w(n[o], e[o], r) : s(e[o], r);
52
+ }), t;
53
53
  }
54
- function y(t, e, r) {
54
+ function $(n, e, r) {
55
55
  if (d(e)) {
56
- const n = s(e, r);
57
- return n.push(...s(t, r)), n;
56
+ const t = s(e, r);
57
+ return t.push(...s(n, r)), t;
58
58
  } else
59
- return s(t, r);
59
+ return s(n, r);
60
60
  }
61
- function s(t, e) {
61
+ function s(n, e) {
62
62
  const { isDeepClone: r = !0 } = e || {};
63
- return r ? w(t) : t;
63
+ return r ? m(n) : n;
64
64
  }
65
- function P(t, e = 1e3) {
65
+ function P(n, e = 1e3) {
66
66
  let r = null;
67
- return function(...n) {
67
+ return function(...t) {
68
68
  r && clearTimeout(r), r = setTimeout(() => {
69
- t.apply(this, ...n);
69
+ n.apply(this, ...t);
70
70
  }, e);
71
71
  };
72
72
  }
73
- function T(t, e = 1e3) {
73
+ function T(n, e = 1e3) {
74
74
  let r = null;
75
- return function(...n) {
75
+ return function(...t) {
76
76
  if (b(r))
77
- return r = Date.now(), t.apply(this, ...n);
77
+ return r = Date.now(), n.apply(this, ...t);
78
78
  {
79
79
  const i = Date.now();
80
80
  if (i - r >= e)
81
- return r = i, t.apply(this, ...n);
81
+ return r = i, n.apply(this, ...t);
82
82
  }
83
83
  };
84
84
  }
85
- function z(...t) {
86
- return t.reduce((e, r) => function(...n) {
87
- return r(e(...n));
85
+ function z(...n) {
86
+ return n.reduce((e, r) => function(...t) {
87
+ return r(e(...t));
88
88
  });
89
89
  }
90
- function L(...t) {
91
- return t.reduce((e, r) => function(...n) {
92
- return e(r(...n));
90
+ function L(...n) {
91
+ return n.reduce((e, r) => function(...t) {
92
+ return e(r(...t));
93
93
  });
94
94
  }
95
- function _(t) {
95
+ function _(n) {
96
96
  return /^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[1589]))\d{8}$/.test(
97
- t
97
+ n
98
98
  );
99
99
  }
100
- function K(t) {
101
- return /^([\w-])+@([\w-])+(.[\w-])+/.test(t);
100
+ function K(n) {
101
+ return /^([\w-])+@([\w-])+(.[\w-])+/.test(n);
102
102
  }
103
- function B(t) {
104
- return /^[A-Z]+$/.test(t);
103
+ function B(n) {
104
+ return /^[A-Z]+$/.test(n);
105
105
  }
106
- function I(t) {
107
- return !c(t) && /^[a-z]+$/.test(t);
106
+ function I(n) {
107
+ return !c(n) && /^[a-z]+$/.test(n);
108
108
  }
109
- function W(t) {
110
- return /^\d+$/.test(t);
109
+ function W(n) {
110
+ return /^\d+$/.test(n);
111
111
  }
112
- function q(t) {
113
- return /^-?\d{1,3}\.\d{6}$/.test(t);
112
+ function q(n) {
113
+ return /^-?\d{1,3}\.\d{6}$/.test(n);
114
114
  }
115
- function G(t) {
116
- return t === "";
115
+ function G(n) {
116
+ return n === "";
117
117
  }
118
- function H(t) {
119
- return !c(t) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
118
+ function H(n) {
119
+ return !c(n) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(n);
120
120
  }
121
- function J(t) {
122
- return !c(t) && /^[A-Za-z\u4E00-\u9FA5]+$/.test(t);
121
+ function J(n) {
122
+ return !c(n) && /^[A-Za-z\u4E00-\u9FA5]+$/.test(n);
123
123
  }
124
- function Q(t) {
125
- return !c(t) && /^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t);
124
+ function Q(n) {
125
+ return !c(n) && /^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(n);
126
126
  }
127
- function V(t) {
128
- return /^[\dA-Z_]+$/.test(t);
127
+ function V(n) {
128
+ return /^[\dA-Z_]+$/.test(n);
129
129
  }
130
- function X(t) {
131
- return /^[1-9]\d*$/.test(t);
130
+ function X(n) {
131
+ return /^[1-9]\d*$/.test(n);
132
132
  }
133
- function Y(t) {
134
- return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t);
133
+ function Y(n) {
134
+ return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(n);
135
+ }
136
+ function k(n) {
137
+ return Array.isArray(n) ? n : [n];
135
138
  }
136
139
  export {
140
+ k as castArray,
137
141
  z as compose,
138
142
  L as composeRight,
139
143
  P as debounce,
140
- w as deepClone,
141
- O as deepMerge,
142
- x as error,
143
- E as getRandomColor,
144
+ m as deepClone,
145
+ w as deepMerge,
146
+ j as error,
147
+ A as getRandomColor,
144
148
  p as getRandomString,
145
149
  F as hasChanged,
146
- m as hasOwn,
150
+ y as hasOwn,
147
151
  d as isArray,
148
152
  Z as isBoolean,
149
153
  J as isChineseOrEnglish,
150
154
  H as isChineseOrEnglishOrNumber,
151
- a as isDate,
155
+ g as isDate,
152
156
  N as isDef,
153
157
  K as isEmail,
154
158
  G as isEmptyString,
155
159
  l as isFunction,
156
160
  q as isLatitudeOrLongitude,
157
161
  I as isLowerCase,
158
- A as isMap,
162
+ x as isMap,
159
163
  _ as isMobilePhone,
160
164
  b as isNull,
161
165
  W as isNumber,
@@ -172,9 +176,9 @@ export {
172
176
  B as isUpperCase,
173
177
  Q as isUppercaseOrNumbersOrSpecial,
174
178
  V as isUppercaseOrNumbersOrUnderline,
175
- S as log,
176
- g as objectToString,
179
+ E as log,
180
+ a as objectToString,
177
181
  T as throttle,
178
182
  f as toTypeString,
179
- j as warn
183
+ S as warn
180
184
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",