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