@lntvow/utils 2.1.4 → 2.1.6

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 S(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function f(t){return t>10?f(10)+f(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const g=Object.prototype.toString,u=t=>g.call(t);let p=null;function w(t){d(t)&&(p=t)}const A=(t,...n)=>{const e=n.length===0?"":n.length===1?n[0]:n;console.log(`%c ${t} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",e),p&&p(t,e)},C=(...t)=>console.warn(...t),E=(...t)=>console.error(...t),$=t=>u(t)==="[object Map]",j=t=>u(t)==="[object Set]",b=t=>u(t)==="[object Date]",h=t=>u(t)==="[object RegExp]",d=t=>typeof t=="function",v=t=>typeof t=="number",M=t=>typeof t=="string",N=t=>typeof t=="symbol",a=t=>t!==null&&typeof t=="object",U=t=>a(t)&&d(t.then)&&d(t.catch),s=t=>t==null,P=t=>t===void 0,R=t=>t===null,D=t=>t!=null,L=t=>typeof t=="boolean",l=Array.isArray,m=(t,n)=>Object.hasOwn(t,n),x=(t,n)=>t!==n;function O(t){const n=new WeakMap;function e(r){if(b(r))return new Date(r);if(h(r))return new RegExp(r);if(a(r)){if(n.has(r))return n.get(r);let i={};if(l(r)){i=[],n.set(r,i);for(let o=0;o<r.length;o++)i[o]=e(r[o]);return i}n.set(r,i);for(const o in r)m(r,o)&&(i[o]=e(r[o]));return i}else return r}return e(t)}function y(t,n,e){return l(t)?Z(t,n,e):T(t,n,e)}function T(t,n,e){const r=c(n,e);return Object.keys(t).forEach(o=>{s(n[o])?r[o]=c(t[o],e):r[o]=a(t[o])&&a(n[o])?y(t[o],n[o],e):c(n[o],e)}),r}function Z(t,n,e){if(l(n)){const r=c(n,e);return r.push(...c(t,e)),r}else return c(t,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?O(t):t}function F(t,n=500){let e=null;return function(...r){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,r)},n)}}function I(t,n=500){let e=null;return function(...r){if(s(e))return e=Date.now(),t.apply(this,r);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,r)}}}function z(...t){return t.reduce((n,e)=>function(...r){return e(n(...r))})}function _(...t){return t.reduce((n,e)=>function(...r){return n(e(...r))})}function B(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 K(t){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(t)}function W(t){return/^[A-Z]+$/.test(t)}function q(t){return!s(t)&&/^[a-z]+$/.test(t)}function G(t){return/^\d+$/.test(t)}function H(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function J(t){return t===""}function Q(t){return!s(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function V(t){return!s(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function X(t){return!s(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function Y(t){return/^[\dA-Z_]+$/.test(t)}function k(t){return/^[1-9]\d*$/.test(t)}function tt(t){return/^\d+$/.test(t)}function nt(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function et(t){return Array.isArray(t)?t:[t]}exports.castArray=et;exports.compose=z;exports.composeRight=_;exports.debounce=F;exports.deepClone=O;exports.deepMerge=y;exports.error=E;exports.getRandomColor=S;exports.getRandomString=f;exports.hasChanged=x;exports.hasOwn=m;exports.initLog=w;exports.isArray=l;exports.isBoolean=L;exports.isDate=b;exports.isDef=D;exports.isEmptyString=J;exports.isFunction=d;exports.isMap=$;exports.isNull=R;exports.isNumber=v;exports.isObject=a;exports.isPromise=U;exports.isRegExp=h;exports.isSet=j;exports.isString=M;exports.isSymbol=N;exports.isUndef=s;exports.isUndefined=P;exports.log=A;exports.objectToString=g;exports.throttle=I;exports.toTypeString=u;exports.validatorChineseOrEnglish=V;exports.validatorChineseOrEnglishOrNumber=Q;exports.validatorEmail=K;exports.validatorLatitudeOrLongitude=H;exports.validatorLowerCase=q;exports.validatorMobilePhone=B;exports.validatorNumber=G;exports.validatorPositiveFloat=nt;exports.validatorPositiveInt=k;exports.validatorPositiveIntAndZero=tt;exports.validatorUpperCase=W;exports.validatorUppercaseOrNumbersOrSpecial=X;exports.validatorUppercaseOrNumbersOrUnderline=Y;exports.warn=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function S(t){const n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let e="";for(let r=0;r<t;r++){const i=Math.floor(Math.random()*n.length);e+=n.charAt(i)}return e}const p=Object.prototype.toString,u=t=>p.call(t);let f=null;function w(t){d(t)&&(f=t)}const A=(t,...n)=>{const e=n.length===0?"":n.length===1?n[0]:n;console.log(`%c ${t} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",e),f&&f(t,e)},C=(...t)=>console.warn(...t),E=(...t)=>console.error(...t),j=t=>u(t)==="[object Map]",$=t=>u(t)==="[object Set]",g=t=>u(t)==="[object Date]",h=t=>u(t)==="[object RegExp]",d=t=>typeof t=="function",M=t=>typeof t=="number",v=t=>typeof t=="string",N=t=>typeof t=="symbol",a=t=>t!==null&&typeof t=="object",U=t=>a(t)&&d(t.then)&&d(t.catch),s=t=>t==null,P=t=>t===void 0,R=t=>t===null,D=t=>t!=null,x=t=>typeof t=="boolean",l=Array.isArray,b=(t,n)=>Object.hasOwn(t,n),L=(t,n)=>t!==n;function m(t){const n=new WeakMap;function e(r){if(g(r))return new Date(r);if(h(r))return new RegExp(r);if(a(r)){if(n.has(r))return n.get(r);let i={};if(l(r)){i=[],n.set(r,i);for(let o=0;o<r.length;o++)i[o]=e(r[o]);return i}n.set(r,i);for(const o in r)b(r,o)&&(i[o]=e(r[o]));return i}else return r}return e(t)}function O(t,n,e){return l(t)?Z(t,n,e):T(t,n,e)}function T(t,n,e){const r=c(n,e);return Object.keys(t).forEach(o=>{s(n[o])?r[o]=c(t[o],e):r[o]=a(t[o])&&a(n[o])?O(t[o],n[o],e):c(n[o],e)}),r}function Z(t,n,e){if(l(n)){const r=c(n,e);return r.push(...c(t,e)),r}else return c(t,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?m(t):t}function F(t,n=500){let e=null;return function(...r){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,r)},n)}}function I(t,n=500){let e=null;return function(...r){if(s(e))return e=Date.now(),t.apply(this,r);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,r)}}}function z(...t){return t.reduce((n,e)=>function(...r){return e(n(...r))})}function B(...t){return t.reduce((n,e)=>function(...r){return n(e(...r))})}function K(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 _(t){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(t)}function W(t){return/^[A-Z]+$/.test(t)}function q(t){return!s(t)&&/^[a-z]+$/.test(t)}function G(t){return/^\d+$/.test(t)}function H(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function J(t){return t===""}function Q(t){return!s(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function V(t){return!s(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function X(t){return!s(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function Y(t){return/^[\dA-Z_]+$/.test(t)}function k(t){return/^[1-9]\d*$/.test(t)}function tt(t){return/^\d+$/.test(t)}function nt(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function et(t){return Array.isArray(t)?t:[t]}exports.castArray=et;exports.compose=z;exports.composeRight=B;exports.debounce=F;exports.deepClone=m;exports.deepMerge=O;exports.error=E;exports.getRandomColor=y;exports.getRandomString=S;exports.hasChanged=L;exports.hasOwn=b;exports.initLog=w;exports.isArray=l;exports.isBoolean=x;exports.isDate=g;exports.isDef=D;exports.isEmptyString=J;exports.isFunction=d;exports.isMap=j;exports.isNull=R;exports.isNumber=M;exports.isObject=a;exports.isPromise=U;exports.isRegExp=h;exports.isSet=$;exports.isString=v;exports.isSymbol=N;exports.isUndef=s;exports.isUndefined=P;exports.log=A;exports.objectToString=p;exports.throttle=I;exports.toTypeString=u;exports.validatorChineseOrEnglish=V;exports.validatorChineseOrEnglishOrNumber=Q;exports.validatorEmail=_;exports.validatorLatitudeOrLongitude=H;exports.validatorLowerCase=q;exports.validatorMobilePhone=K;exports.validatorNumber=G;exports.validatorPositiveFloat=nt;exports.validatorPositiveInt=k;exports.validatorPositiveIntAndZero=tt;exports.validatorUpperCase=W;exports.validatorUppercaseOrNumbersOrSpecial=X;exports.validatorUppercaseOrNumbersOrUnderline=Y;exports.warn=C;
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare const error: (...arg: unknown[]) => void;
51
51
  export declare function getRandomColor(): string;
52
52
 
53
53
  /**
54
- * @description 获取随机字符串
54
+ * @description 获取随机字符串 大小写字母+数字
55
55
  * @param {Number} number 长度
56
56
  * @return {String} 随机字符串
57
57
  *
package/dist/index.mjs CHANGED
@@ -1,28 +1,34 @@
1
- function A() {
1
+ function O() {
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 $(t) {
5
+ const n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
6
+ let r = "";
7
+ for (let e = 0; e < t; e++) {
8
+ const i = Math.floor(Math.random() * n.length);
9
+ r += n.charAt(i);
10
+ }
11
+ return r;
6
12
  }
7
- const g = Object.prototype.toString, f = (t) => g.call(t);
13
+ const p = Object.prototype.toString, f = (t) => p.call(t);
8
14
  let d = null;
9
- function E(t) {
15
+ function j(t) {
10
16
  a(t) && (d = t);
11
17
  }
12
- const S = (t, ...n) => {
18
+ const E = (t, ...n) => {
13
19
  const r = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
14
20
  console.log(
15
21
  `%c ${t} `,
16
22
  "padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
17
23
  r
18
24
  ), d && d(t, r);
19
- }, j = (...t) => console.warn(...t), C = (...t) => console.error(...t), M = (t) => f(t) === "[object Map]", x = (t) => f(t) === "[object Set]", h = (t) => f(t) === "[object Date]", b = (t) => f(t) === "[object RegExp]", a = (t) => typeof t == "function", D = (t) => typeof t == "number", N = (t) => typeof t == "string", R = (t) => typeof t == "symbol", u = (t) => t !== null && typeof t == "object", U = (t) => u(t) && a(t.then) && a(t.catch), c = (t) => t == null, Z = (t) => t === void 0, P = (t) => t === null, F = (t) => t != null, L = (t) => typeof t == "boolean", l = Array.isArray, y = (t, n) => Object.hasOwn(t, n), T = (t, n) => t !== n;
25
+ }, S = (...t) => console.warn(...t), C = (...t) => console.error(...t), M = (t) => f(t) === "[object Map]", x = (t) => f(t) === "[object Set]", h = (t) => f(t) === "[object Date]", g = (t) => f(t) === "[object RegExp]", a = (t) => typeof t == "function", D = (t) => typeof t == "number", N = (t) => typeof t == "string", R = (t) => typeof t == "symbol", u = (t) => t !== null && typeof t == "object", U = (t) => u(t) && a(t.then) && a(t.catch), c = (t) => t == null, Z = (t) => t === void 0, P = (t) => t === null, F = (t) => t != null, L = (t) => typeof t == "boolean", l = Array.isArray, b = (t, n) => Object.hasOwn(t, n), T = (t, n) => t !== n;
20
26
  function m(t) {
21
27
  const n = /* @__PURE__ */ new WeakMap();
22
28
  function r(e) {
23
29
  if (h(e))
24
30
  return new Date(e);
25
- if (b(e))
31
+ if (g(e))
26
32
  return new RegExp(e);
27
33
  if (u(e)) {
28
34
  if (n.has(e))
@@ -36,23 +42,23 @@ function m(t) {
36
42
  }
37
43
  n.set(e, i);
38
44
  for (const o in e)
39
- y(e, o) && (i[o] = r(e[o]));
45
+ b(e, o) && (i[o] = r(e[o]));
40
46
  return i;
41
47
  } else
42
48
  return e;
43
49
  }
44
50
  return r(t);
45
51
  }
46
- function w(t, n, r) {
47
- return l(t) ? $(t, n, r) : O(t, n, r);
52
+ function y(t, n, r) {
53
+ return l(t) ? A(t, n, r) : w(t, n, r);
48
54
  }
49
- function O(t, n, r) {
55
+ function w(t, n, r) {
50
56
  const e = s(n, r);
51
57
  return Object.keys(t).forEach((o) => {
52
- c(n[o]) ? e[o] = s(t[o], r) : e[o] = u(t[o]) && u(n[o]) ? w(t[o], n[o], r) : s(n[o], r);
58
+ c(n[o]) ? e[o] = s(t[o], r) : e[o] = u(t[o]) && u(n[o]) ? y(t[o], n[o], r) : s(n[o], r);
53
59
  }), e;
54
60
  }
55
- function $(t, n, r) {
61
+ function A(t, n, r) {
56
62
  if (l(n)) {
57
63
  const e = s(n, r);
58
64
  return e.push(...s(t, r)), e;
@@ -71,7 +77,7 @@ function z(t, n = 500) {
71
77
  }, n);
72
78
  };
73
79
  }
74
- function _(t, n = 500) {
80
+ function I(t, n = 500) {
75
81
  let r = null;
76
82
  return function(...e) {
77
83
  if (c(r))
@@ -83,12 +89,12 @@ function _(t, n = 500) {
83
89
  }
84
90
  };
85
91
  }
86
- function I(...t) {
92
+ function K(...t) {
87
93
  return t.reduce((n, r) => function(...e) {
88
94
  return r(n(...e));
89
95
  });
90
96
  }
91
- function K(...t) {
97
+ function _(...t) {
92
98
  return t.reduce((n, r) => function(...e) {
93
99
  return n(r(...e));
94
100
  });
@@ -142,17 +148,17 @@ function rt(t) {
142
148
  }
143
149
  export {
144
150
  rt as castArray,
145
- I as compose,
146
- K as composeRight,
151
+ K as compose,
152
+ _ as composeRight,
147
153
  z as debounce,
148
154
  m as deepClone,
149
- w as deepMerge,
155
+ y as deepMerge,
150
156
  C as error,
151
- A as getRandomColor,
152
- p as getRandomString,
157
+ O as getRandomColor,
158
+ $ as getRandomString,
153
159
  T as hasChanged,
154
- y as hasOwn,
155
- E as initLog,
160
+ b as hasOwn,
161
+ j as initLog,
156
162
  l as isArray,
157
163
  L as isBoolean,
158
164
  h as isDate,
@@ -164,15 +170,15 @@ export {
164
170
  D as isNumber,
165
171
  u as isObject,
166
172
  U as isPromise,
167
- b as isRegExp,
173
+ g as isRegExp,
168
174
  x as isSet,
169
175
  N as isString,
170
176
  R as isSymbol,
171
177
  c as isUndef,
172
178
  Z as isUndefined,
173
- S as log,
174
- g as objectToString,
175
- _ as throttle,
179
+ E as log,
180
+ p as objectToString,
181
+ I as throttle,
176
182
  f as toTypeString,
177
183
  X as validatorChineseOrEnglish,
178
184
  V as validatorChineseOrEnglishOrNumber,
@@ -187,5 +193,5 @@ export {
187
193
  q as validatorUpperCase,
188
194
  Y as validatorUppercaseOrNumbersOrSpecial,
189
195
  k as validatorUppercaseOrNumbersOrUnderline,
190
- j as warn
196
+ S as warn
191
197
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,6 +33,9 @@
33
33
  "prettier --write"
34
34
  ]
35
35
  },
36
+ "dependencies": {
37
+ "vconsole": "^3.15.1"
38
+ },
36
39
  "scripts": {
37
40
  "dev": "vite",
38
41
  "test": "vitest",