@lntvow/utils 1.8.3 → 1.8.5
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 +7 -2
- package/dist/index.mjs +44 -40
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function d(t){return t>10?d(10)+d(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const p=Object.prototype.toString,u=t=>p.call(t),y=(...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)),C=(...t)=>console.warn(...t),E=(...t)=>console.error(...t),A=t=>u(t)==="[object Map]",$=t=>u(t)==="[object Set]",a=t=>u(t)==="[object Date]",g=t=>u(t)==="[object RegExp]",l=t=>typeof t=="function",j=t=>typeof t=="string",x=t=>typeof t=="symbol",c=t=>t!==null&&typeof t=="object",M=t=>c(t)&&l(t.then)&&l(t.catch),h=t=>t==null,b=t=>t===null;function N(t){return t!=null}function R(t){return typeof t=="boolean"}const f=Array.isArray,m=(t,n)=>Object.hasOwn(t,n),U=(t,n)=>t!==n;function O(t){const n=new WeakMap;function r(e){if(a(e))return new Date(e);if(g(e))return new RegExp(e);if(c(e)){if(n.has(e))return n.get(e);let o={};if(f(e)){o=[],n.set(e,o);for(let i=0;i<e.length;i++)o[i]=r(e[i]);return o}n.set(e,o);for(const i in e)m(e,i)&&(o[i]=r(e[i]));return o}else return e}return r(t)}function S(t,n,r){return f(t)?P(t,n,r):D(t,n,r)}function D(t,n,r){const e=s(n,r);return Object.keys(t).forEach(i=>{h(n[i])?e[i]=s(t[i],r):e[i]=c(t[i])&&c(n[i])?S(t[i],n[i],r):s(n[i],r)}),e}function P(t,n,r){if(f(n)){const e=s(n,r);return e.push(...s(t,r)),e}else return s(t,r)}function s(t,n){const{isDeepClone:r=!0}=n||{};return r?O(t):t}function T(t,n=1e3){let r=null;return function(...e){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,...e)},n)}}function F(t,n=1e3){let r=null;return function(...e){if(b(r))return r=Date.now(),t.apply(this,...e);{const o=Date.now();if(o-r>=n)return r=o,t.apply(this,...e)}}}function L(...t){return t.reduce((n,r)=>function(...e){return r(n(...e))})}function Z(...t){return t.reduce((n,r)=>function(...e){return n(r(...e))})}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 B(t){return/^([\w-])+@([\w-])+(.[\w-])+/.test(t)}function I(t){return/^[A-Z]+$/.test(t)}function K(t){return/^[a-z]+$/.test(t)}function _(t){return/^\d+$/.test(t)}function W(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function q(t){return/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function G(t){return/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function H(t){return/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function J(t){return/^[\d!#$%&*@A-Z^]+$/.test(t)}function Q(t){return/^[\dA-Z_]+$/.test(t)}function V(t){return/^[1-9]\d*$/.test(t)}function X(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}exports.compose=L;exports.composeRight=Z;exports.debounce=T;exports.deepClone=O;exports.deepMerge=S;exports.error=E;exports.getRandomColor=w;exports.getRandomString=d;exports.hasChanged=U;exports.hasOwn=m;exports.isAlphanumericText=q;exports.isArray=f;exports.isBoolean=R;exports.isChineseOrEnglish=G;exports.isChineseOrEnglishOrNumber=H;exports.isDate=a;exports.isDef=N;exports.isEmail=B;exports.isFunction=l;exports.isLatitudeOrLongitude=W;exports.isLowerCase=K;exports.isMap=A;exports.isMobilePhone=z;exports.isNull=b;exports.isNumber=_;exports.isObject=c;exports.isPositiveFloat=X;exports.isPositiveInt=V;exports.isPromise=M;exports.isRegExp=g;exports.isSet=$;exports.isString=j;exports.isSymbol=x;exports.isUndef=h;exports.isUpperCase=I;exports.isUppercaseOrNumbersOrSpecial=J;exports.isUppercaseOrNumbersOrUnderline=Q;exports.log=y;exports.objectToString=p;exports.throttle=F;exports.toTypeString=u;exports.warn=C;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare function composeRight(...fns: ((...args: any[]) => any)[]): (...a
|
|
|
18
18
|
* @description 防抖函数
|
|
19
19
|
* @param target 目标函数
|
|
20
20
|
* @param wait 等待时间 默认 1000ms
|
|
21
|
-
* @example debounce(() => console.log('debounce'),500)
|
|
21
|
+
* @example debounce(() => console.log('debounce'), 500)
|
|
22
22
|
*/
|
|
23
23
|
export declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
|
|
24
24
|
|
|
@@ -149,6 +149,11 @@ export declare function isUpperCase(value: string): boolean;
|
|
|
149
149
|
*/
|
|
150
150
|
export declare function isUppercaseOrNumbersOrSpecial(value: string): boolean;
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @description 校验大写字母、数字、_
|
|
154
|
+
*/
|
|
155
|
+
export declare function isUppercaseOrNumbersOrUnderline(value: string): boolean;
|
|
156
|
+
|
|
152
157
|
export declare const log: (...arg: unknown[]) => void;
|
|
153
158
|
|
|
154
159
|
export declare const objectToString: () => string;
|
|
@@ -165,7 +170,7 @@ declare interface Options {
|
|
|
165
170
|
* @description 节流函数
|
|
166
171
|
* @param target 目标函数
|
|
167
172
|
* @param wait 等待时间 默认 1000ms
|
|
168
|
-
* @example throttle(() =>
|
|
173
|
+
* @example throttle(() => console.log('hello world'), 500)
|
|
169
174
|
*/
|
|
170
175
|
export declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
|
|
171
176
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function y() {
|
|
2
2
|
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
3
3
|
}
|
|
4
4
|
function d(t) {
|
|
@@ -9,14 +9,14 @@ const l = Object.prototype.toString, u = (t) => l.call(t), E = (...t) => console
|
|
|
9
9
|
"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
|
|
10
10
|
t.slice(1)
|
|
11
11
|
), j = (...t) => console.warn(...t), x = (...t) => console.error(...t), S = (t) => u(t) === "[object Map]", C = (t) => u(t) === "[object Set]", a = (t) => u(t) === "[object Date]", g = (t) => u(t) === "[object RegExp]", p = (t) => typeof t == "function", M = (t) => typeof t == "string", D = (t) => typeof t == "symbol", c = (t) => t !== null && typeof t == "object", R = (t) => c(t) && p(t.then) && p(t.catch), h = (t) => t == null, b = (t) => t === null;
|
|
12
|
-
function
|
|
12
|
+
function Z(t) {
|
|
13
13
|
return t != null;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function F(t) {
|
|
16
16
|
return typeof t == "boolean";
|
|
17
17
|
}
|
|
18
|
-
const f = Array.isArray,
|
|
19
|
-
function
|
|
18
|
+
const f = Array.isArray, m = (t, e) => Object.hasOwn(t, e), N = (t, e) => t !== e;
|
|
19
|
+
function w(t) {
|
|
20
20
|
const e = /* @__PURE__ */ new WeakMap();
|
|
21
21
|
function r(n) {
|
|
22
22
|
if (a(n))
|
|
@@ -35,23 +35,23 @@ function m(t) {
|
|
|
35
35
|
}
|
|
36
36
|
e.set(n, i);
|
|
37
37
|
for (const o in n)
|
|
38
|
-
|
|
38
|
+
m(n, o) && (i[o] = r(n[o]));
|
|
39
39
|
return i;
|
|
40
40
|
} else
|
|
41
41
|
return n;
|
|
42
42
|
}
|
|
43
43
|
return r(t);
|
|
44
44
|
}
|
|
45
|
-
function $(t, e, r) {
|
|
46
|
-
return f(t) ? y(t, e, r) : O(t, e, r);
|
|
47
|
-
}
|
|
48
45
|
function O(t, e, r) {
|
|
46
|
+
return f(t) ? A(t, e, r) : $(t, e, r);
|
|
47
|
+
}
|
|
48
|
+
function $(t, e, r) {
|
|
49
49
|
const n = s(e, r);
|
|
50
50
|
return Object.keys(t).forEach((o) => {
|
|
51
|
-
h(e[o]) ? n[o] = s(t[o], r) : n[o] = c(t[o]) && c(e[o]) ?
|
|
51
|
+
h(e[o]) ? n[o] = s(t[o], r) : n[o] = c(t[o]) && c(e[o]) ? O(t[o], e[o], r) : s(e[o], r);
|
|
52
52
|
}), n;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function A(t, e, r) {
|
|
55
55
|
if (f(e)) {
|
|
56
56
|
const n = s(e, r);
|
|
57
57
|
return n.push(...s(t, r)), n;
|
|
@@ -60,9 +60,9 @@ function y(t, e, r) {
|
|
|
60
60
|
}
|
|
61
61
|
function s(t, e) {
|
|
62
62
|
const { isDeepClone: r = !0 } = e || {};
|
|
63
|
-
return r ?
|
|
63
|
+
return r ? w(t) : t;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function T(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 z(t, e = 1e3) {
|
|
|
70
70
|
}, e);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function U(t, e = 1e3) {
|
|
74
74
|
let r = null;
|
|
75
75
|
return function(...n) {
|
|
76
76
|
if (b(r))
|
|
@@ -82,17 +82,17 @@ function N(t, e = 1e3) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function z(...t) {
|
|
86
86
|
return t.reduce((e, r) => function(...n) {
|
|
87
87
|
return r(e(...n));
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function P(...t) {
|
|
91
91
|
return t.reduce((e, r) => function(...n) {
|
|
92
92
|
return e(r(...n));
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function L(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,16 +100,16 @@ function U(t) {
|
|
|
100
100
|
function K(t) {
|
|
101
101
|
return /^([\w-])+@([\w-])+(.[\w-])+/.test(t);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function _(t) {
|
|
104
104
|
return /^[A-Z]+$/.test(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function B(t) {
|
|
107
107
|
return /^[a-z]+$/.test(t);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function I(t) {
|
|
110
110
|
return /^\d+$/.test(t);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function W(t) {
|
|
113
113
|
return /^-?\d{1,3}\.\d{6}$/.test(t);
|
|
114
114
|
}
|
|
115
115
|
function q(t) {
|
|
@@ -125,51 +125,55 @@ function J(t) {
|
|
|
125
125
|
return /^[\d!#$%&*@A-Z^]+$/.test(t);
|
|
126
126
|
}
|
|
127
127
|
function Q(t) {
|
|
128
|
-
return /^[
|
|
128
|
+
return /^[\dA-Z_]+$/.test(t);
|
|
129
129
|
}
|
|
130
130
|
function V(t) {
|
|
131
|
+
return /^[1-9]\d*$/.test(t);
|
|
132
|
+
}
|
|
133
|
+
function X(t) {
|
|
131
134
|
return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t);
|
|
132
135
|
}
|
|
133
136
|
export {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
z as compose,
|
|
138
|
+
P as composeRight,
|
|
139
|
+
T as debounce,
|
|
140
|
+
w as deepClone,
|
|
141
|
+
O as deepMerge,
|
|
139
142
|
x as error,
|
|
140
|
-
|
|
143
|
+
y as getRandomColor,
|
|
141
144
|
d as getRandomString,
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
N as hasChanged,
|
|
146
|
+
m as hasOwn,
|
|
144
147
|
q as isAlphanumericText,
|
|
145
148
|
f as isArray,
|
|
146
|
-
|
|
149
|
+
F as isBoolean,
|
|
147
150
|
G as isChineseOrEnglish,
|
|
148
151
|
H as isChineseOrEnglishOrNumber,
|
|
149
152
|
a as isDate,
|
|
150
|
-
|
|
153
|
+
Z as isDef,
|
|
151
154
|
K as isEmail,
|
|
152
155
|
p as isFunction,
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
W as isLatitudeOrLongitude,
|
|
157
|
+
B as isLowerCase,
|
|
155
158
|
S as isMap,
|
|
156
|
-
|
|
159
|
+
L as isMobilePhone,
|
|
157
160
|
b as isNull,
|
|
158
|
-
|
|
161
|
+
I as isNumber,
|
|
159
162
|
c as isObject,
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
X as isPositiveFloat,
|
|
164
|
+
V as isPositiveInt,
|
|
162
165
|
R as isPromise,
|
|
163
166
|
g as isRegExp,
|
|
164
167
|
C as isSet,
|
|
165
168
|
M as isString,
|
|
166
169
|
D as isSymbol,
|
|
167
170
|
h as isUndef,
|
|
168
|
-
|
|
171
|
+
_ as isUpperCase,
|
|
169
172
|
J as isUppercaseOrNumbersOrSpecial,
|
|
173
|
+
Q as isUppercaseOrNumbersOrUnderline,
|
|
170
174
|
E as log,
|
|
171
175
|
l as objectToString,
|
|
172
|
-
|
|
176
|
+
U as throttle,
|
|
173
177
|
u as toTypeString,
|
|
174
178
|
j as warn
|
|
175
179
|
};
|