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