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