@lntvow/utils 2.1.2 → 2.1.4
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 +1 -1
- package/dist/index.mjs +54 -49
- package/package.json +1 -1
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)=>{console.log(`%c ${t} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -10,82 +10,87 @@ function E(t) {
|
|
|
10
10
|
a(t) && (d = t);
|
|
11
11
|
}
|
|
12
12
|
const S = (t, ...n) => {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const r = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
|
|
14
|
+
console.log(
|
|
15
|
+
`%c ${t} `,
|
|
16
|
+
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
17
|
+
r
|
|
18
|
+
), 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;
|
|
15
20
|
function m(t) {
|
|
16
21
|
const n = /* @__PURE__ */ new WeakMap();
|
|
17
|
-
function e
|
|
18
|
-
if (
|
|
19
|
-
return new Date(
|
|
20
|
-
if (
|
|
21
|
-
return new RegExp(
|
|
22
|
-
if (u(
|
|
23
|
-
if (n.has(
|
|
24
|
-
return n.get(
|
|
22
|
+
function r(e) {
|
|
23
|
+
if (h(e))
|
|
24
|
+
return new Date(e);
|
|
25
|
+
if (b(e))
|
|
26
|
+
return new RegExp(e);
|
|
27
|
+
if (u(e)) {
|
|
28
|
+
if (n.has(e))
|
|
29
|
+
return n.get(e);
|
|
25
30
|
let i = {};
|
|
26
|
-
if (l(
|
|
27
|
-
i = [], n.set(
|
|
28
|
-
for (let o = 0; o <
|
|
29
|
-
i[o] = e
|
|
31
|
+
if (l(e)) {
|
|
32
|
+
i = [], n.set(e, i);
|
|
33
|
+
for (let o = 0; o < e.length; o++)
|
|
34
|
+
i[o] = r(e[o]);
|
|
30
35
|
return i;
|
|
31
36
|
}
|
|
32
|
-
n.set(
|
|
33
|
-
for (const o in
|
|
34
|
-
y(
|
|
37
|
+
n.set(e, i);
|
|
38
|
+
for (const o in e)
|
|
39
|
+
y(e, o) && (i[o] = r(e[o]));
|
|
35
40
|
return i;
|
|
36
41
|
} else
|
|
37
|
-
return
|
|
42
|
+
return e;
|
|
38
43
|
}
|
|
39
|
-
return
|
|
44
|
+
return r(t);
|
|
40
45
|
}
|
|
41
|
-
function w(t, n,
|
|
42
|
-
return l(t) ? $(t, n,
|
|
46
|
+
function w(t, n, r) {
|
|
47
|
+
return l(t) ? $(t, n, r) : O(t, n, r);
|
|
43
48
|
}
|
|
44
|
-
function O(t, n,
|
|
45
|
-
const
|
|
49
|
+
function O(t, n, r) {
|
|
50
|
+
const e = s(n, r);
|
|
46
51
|
return Object.keys(t).forEach((o) => {
|
|
47
|
-
c(n[o]) ?
|
|
48
|
-
}),
|
|
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);
|
|
53
|
+
}), e;
|
|
49
54
|
}
|
|
50
|
-
function $(t, n,
|
|
55
|
+
function $(t, n, r) {
|
|
51
56
|
if (l(n)) {
|
|
52
|
-
const
|
|
53
|
-
return
|
|
57
|
+
const e = s(n, r);
|
|
58
|
+
return e.push(...s(t, r)), e;
|
|
54
59
|
} else
|
|
55
|
-
return s(t,
|
|
60
|
+
return s(t, r);
|
|
56
61
|
}
|
|
57
62
|
function s(t, n) {
|
|
58
|
-
const { isDeepClone:
|
|
59
|
-
return
|
|
63
|
+
const { isDeepClone: r = !0 } = n || {};
|
|
64
|
+
return r ? m(t) : t;
|
|
60
65
|
}
|
|
61
66
|
function z(t, n = 500) {
|
|
62
|
-
let
|
|
63
|
-
return function(...
|
|
64
|
-
|
|
65
|
-
t.apply(this,
|
|
67
|
+
let r = null;
|
|
68
|
+
return function(...e) {
|
|
69
|
+
r && clearTimeout(r), r = setTimeout(() => {
|
|
70
|
+
t.apply(this, e);
|
|
66
71
|
}, n);
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
function _(t, n = 500) {
|
|
70
|
-
let
|
|
71
|
-
return function(...
|
|
72
|
-
if (c(
|
|
73
|
-
return
|
|
75
|
+
let r = null;
|
|
76
|
+
return function(...e) {
|
|
77
|
+
if (c(r))
|
|
78
|
+
return r = Date.now(), t.apply(this, e);
|
|
74
79
|
{
|
|
75
80
|
const i = Date.now();
|
|
76
|
-
if (i -
|
|
77
|
-
return
|
|
81
|
+
if (i - r >= n)
|
|
82
|
+
return r = i, t.apply(this, e);
|
|
78
83
|
}
|
|
79
84
|
};
|
|
80
85
|
}
|
|
81
86
|
function I(...t) {
|
|
82
|
-
return t.reduce((n,
|
|
83
|
-
return
|
|
87
|
+
return t.reduce((n, r) => function(...e) {
|
|
88
|
+
return r(n(...e));
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
91
|
function K(...t) {
|
|
87
|
-
return t.reduce((n,
|
|
88
|
-
return n(
|
|
92
|
+
return t.reduce((n, r) => function(...e) {
|
|
93
|
+
return n(r(...e));
|
|
89
94
|
});
|
|
90
95
|
}
|
|
91
96
|
function B(t) {
|
|
@@ -150,17 +155,17 @@ export {
|
|
|
150
155
|
E as initLog,
|
|
151
156
|
l as isArray,
|
|
152
157
|
L as isBoolean,
|
|
153
|
-
|
|
158
|
+
h as isDate,
|
|
154
159
|
F as isDef,
|
|
155
160
|
Q as isEmptyString,
|
|
156
161
|
a as isFunction,
|
|
157
162
|
M as isMap,
|
|
158
163
|
P as isNull,
|
|
159
|
-
|
|
164
|
+
D as isNumber,
|
|
160
165
|
u as isObject,
|
|
161
166
|
U as isPromise,
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
b as isRegExp,
|
|
168
|
+
x as isSet,
|
|
164
169
|
N as isString,
|
|
165
170
|
R as isSymbol,
|
|
166
171
|
c as isUndef,
|