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