@lntvow/utils 2.1.1 → 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 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)=>{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):""),p&&p()},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,e)=>Object.hasOwn(t,e),T=(t,e)=>t!==e;function O(t){const e=new WeakMap;function r(n){if(b(n))return new Date(n);if(h(n))return new RegExp(n);if(a(n)){if(e.has(n))return e.get(n);let i={};if(l(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)m(n,o)&&(i[o]=r(n[o]));return i}else return n}return r(t)}function y(t,e,r){return l(t)?x(t,e,r):Z(t,e,r)}function Z(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])?y(t[o],e[o],r):c(e[o],r)}),n}function x(t,e,r){if(l(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?O(t):t}function F(t,e=500){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,n)},e)}}function I(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 z(...t){return t.reduce((e,r)=>function(...n){return r(e(...n))})}function _(...t){return t.reduce((e,r)=>function(...n){return e(r(...n))})}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;
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
@@ -102,7 +102,7 @@ export declare const isUndef: (val: unknown) => val is null | undefined;
102
102
 
103
103
  export declare const isUndefined: (val: unknown) => val is undefined;
104
104
 
105
- export declare const log: (...arg: unknown[]) => void;
105
+ export declare const log: (name: unknown, ...arg: unknown[]) => void;
106
106
 
107
107
  export declare const objectToString: () => string;
108
108
 
package/dist/index.mjs CHANGED
@@ -9,87 +9,83 @@ let d = null;
9
9
  function E(t) {
10
10
  a(t) && (d = t);
11
11
  }
12
- const S = (...t) => {
13
- console.log(
14
- `%c ${t[0]} `,
15
- "padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
16
- t.slice(1).length > 0 ? t.slice(1) : ""
17
- ), d && d();
18
- }, j = (...t) => console.warn(...t), C = (...t) => console.error(...t), M = (t) => f(t) === "[object Map]", D = (t) => f(t) === "[object Set]", h = (t) => f(t) === "[object Date]", b = (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, m = (t, r) => Object.hasOwn(t, r), T = (t, r) => t !== r;
19
- function y(t) {
20
- const r = /* @__PURE__ */ new WeakMap();
21
- function e(n) {
22
- if (h(n))
23
- return new Date(n);
24
- if (b(n))
25
- return new RegExp(n);
26
- if (u(n)) {
27
- if (r.has(n))
28
- return r.get(n);
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;
15
+ function m(t) {
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);
29
25
  let i = {};
30
- if (l(n)) {
31
- i = [], r.set(n, i);
32
- for (let o = 0; o < n.length; o++)
33
- 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]);
34
30
  return i;
35
31
  }
36
- r.set(n, i);
37
- for (const o in n)
38
- m(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]));
39
35
  return i;
40
36
  } else
41
- return n;
37
+ return r;
42
38
  }
43
39
  return e(t);
44
40
  }
45
- function w(t, r, e) {
46
- return l(t) ? $(t, r, e) : O(t, r, e);
41
+ function w(t, n, e) {
42
+ return l(t) ? $(t, n, e) : O(t, n, e);
47
43
  }
48
- function O(t, r, e) {
49
- const n = s(r, e);
44
+ function O(t, n, e) {
45
+ const r = s(n, e);
50
46
  return Object.keys(t).forEach((o) => {
51
- c(r[o]) ? n[o] = s(t[o], e) : n[o] = u(t[o]) && u(r[o]) ? w(t[o], r[o], e) : s(r[o], e);
52
- }), 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;
53
49
  }
54
- function $(t, r, e) {
55
- if (l(r)) {
56
- const n = s(r, e);
57
- 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;
58
54
  } else
59
55
  return s(t, e);
60
56
  }
61
- function s(t, r) {
62
- const { isDeepClone: e = !0 } = r || {};
63
- return e ? y(t) : t;
57
+ function s(t, n) {
58
+ const { isDeepClone: e = !0 } = n || {};
59
+ return e ? m(t) : t;
64
60
  }
65
- function z(t, r = 500) {
61
+ function z(t, n = 500) {
66
62
  let e = null;
67
- return function(...n) {
63
+ return function(...r) {
68
64
  e && clearTimeout(e), e = setTimeout(() => {
69
- t.apply(this, n);
70
- }, r);
65
+ t.apply(this, r);
66
+ }, n);
71
67
  };
72
68
  }
73
- function _(t, r = 500) {
69
+ function _(t, n = 500) {
74
70
  let e = null;
75
- return function(...n) {
71
+ return function(...r) {
76
72
  if (c(e))
77
- return e = Date.now(), t.apply(this, n);
73
+ return e = Date.now(), t.apply(this, r);
78
74
  {
79
75
  const i = Date.now();
80
- if (i - e >= r)
81
- return e = i, t.apply(this, n);
76
+ if (i - e >= n)
77
+ return e = i, t.apply(this, r);
82
78
  }
83
79
  };
84
80
  }
85
81
  function I(...t) {
86
- return t.reduce((r, e) => function(...n) {
87
- return e(r(...n));
82
+ return t.reduce((n, e) => function(...r) {
83
+ return e(n(...r));
88
84
  });
89
85
  }
90
86
  function K(...t) {
91
- return t.reduce((r, e) => function(...n) {
92
- return r(e(...n));
87
+ return t.reduce((n, e) => function(...r) {
88
+ return n(e(...r));
93
89
  });
94
90
  }
95
91
  function B(t) {
@@ -144,17 +140,17 @@ export {
144
140
  I as compose,
145
141
  K as composeRight,
146
142
  z as debounce,
147
- y as deepClone,
143
+ m as deepClone,
148
144
  w as deepMerge,
149
145
  C as error,
150
146
  A as getRandomColor,
151
147
  p as getRandomString,
152
148
  T as hasChanged,
153
- m as hasOwn,
149
+ y as hasOwn,
154
150
  E as initLog,
155
151
  l as isArray,
156
152
  L as isBoolean,
157
- h as isDate,
153
+ b as isDate,
158
154
  F as isDef,
159
155
  Q as isEmptyString,
160
156
  a as isFunction,
@@ -163,7 +159,7 @@ export {
163
159
  x as isNumber,
164
160
  u as isObject,
165
161
  U as isPromise,
166
- b as isRegExp,
162
+ h as isRegExp,
167
163
  D as isSet,
168
164
  N as isString,
169
165
  R as isSymbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",