@lntvow/utils 1.8.23 → 2.0.0
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 -2
- package/dist/index.mjs +29 -29
- 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 l(t){return t>10?l(10)+l(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const a=Object.prototype.toString,f=t=>a.call(t),S=(...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):""),w=(...t)=>console.warn(...t),A=(...t)=>console.error(...t),E=t=>f(t)==="[object Map]",C=t=>f(t)==="[object Set]",g=t=>f(t)==="[object Date]",h=t=>f(t)==="[object RegExp]",p=t=>typeof t=="function",$=t=>typeof t=="string",j=t=>typeof t=="symbol",u=t=>t!==null&&typeof t=="object",M=t=>u(t)&&p(t.then)&&p(t.catch),o=t=>t==null,U=t=>t===void 0,P=t=>t===null;function N(t){return t!=null}function R(t){return typeof t=="boolean"}const d=Array.isArray,b=(t,e)=>Object.hasOwn(t,e),D=(t,e)=>t!==e;function m(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 s={};if(d(n)){s=[],e.set(n,s);for(let i=0;i<n.length;i++)s[i]=r(n[i]);return s}e.set(n,s);for(const i in n)b(n,i)&&(s[i]=r(n[i]));return s}else return n}return r(t)}function O(t,e,r){return d(t)?Z(t,e,r):T(t,e,r)}function T(t,e,r){const n=c(e,r);return Object.keys(t).forEach(i=>{o(e[i])?n[i]=c(t[i],r):n[i]=u(t[i])&&u(e[i])?O(t[i],e[i],r):c(e[i],r)}),n}function Z(t,e,r){if(d(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?m(t):t}function x(t,e=500){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,n)},e)}}function F(t,e=500){let r=null;return function(...n){if(o(r))return r=Date.now(),t.apply(this,n);{const s=Date.now();if(s-r>=e)return r=s,t.apply(this,n)}}}function L(...t){return t.reduce((e,r)=>function(...n){return r(e(...n))})}function I(...t){return t.reduce((e,r)=>function(...n){return e(r(...n))})}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 _(t){return/^([\w-])+@([\w-])+(.[\w-])+/.test(t)}function B(t){return/^[A-Z]+$/.test(t)}function K(t){return!o(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!o(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function J(t){return!o(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function Q(t){return!o(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/^\d+$/.test(t)}function k(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function v(t){return Array.isArray(t)?t:[t]}exports.castArray=v;exports.compose=L;exports.composeRight=I;exports.debounce=x;exports.deepClone=m;exports.deepMerge=O;exports.error=A;exports.getRandomColor=y;exports.getRandomString=l;exports.hasChanged=D;exports.hasOwn=b;exports.isArray=d;exports.isBoolean=R;exports.isChineseOrEnglish=J;exports.isChineseOrEnglishOrNumber=H;exports.isDate=g;exports.isDef=N;exports.isEmail=_;exports.isEmptyString=G;exports.isFunction=p;exports.isLatitudeOrLongitude=q;exports.isLowerCase=K;exports.isMap=E;exports.isMobilePhone=z;exports.isNull=P;exports.isNumber=W;exports.isObject=u;exports.isPositiveFloat=k;exports.isPositiveInt=X;exports.isPositiveIntAndZero=Y;exports.isPromise=M;exports.isRegExp=h;exports.isSet=C;exports.isString=$;exports.isSymbol=j;exports.isUndef=o;exports.isUndefined=U;exports.isUpperCase=B;exports.isUppercaseOrNumbersOrSpecial=Q;exports.isUppercaseOrNumbersOrUnderline=V;exports.log=S;exports.objectToString=a;exports.throttle=F;exports.toTypeString=f;exports.warn=w;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function composeRight(...fns: ((...args: any[]) => any)[]): (...a
|
|
|
19
19
|
/**
|
|
20
20
|
* @description 防抖函数
|
|
21
21
|
* @param target 目标函数
|
|
22
|
-
* @param wait 等待时间 默认
|
|
22
|
+
* @param wait 等待时间 默认 500ms
|
|
23
23
|
* @example debounce(() => console.log('debounce'), 500)
|
|
24
24
|
*/
|
|
25
25
|
export declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
|
|
@@ -178,7 +178,7 @@ declare interface Options {
|
|
|
178
178
|
/**
|
|
179
179
|
* @description 节流函数
|
|
180
180
|
* @param target 目标函数
|
|
181
|
-
* @param wait 等待时间 默认
|
|
181
|
+
* @param wait 等待时间 默认 500ms
|
|
182
182
|
* @example throttle(() => console.log('hello world'), 500)
|
|
183
183
|
*/
|
|
184
184
|
export declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
function
|
|
1
|
+
function $() {
|
|
2
2
|
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
3
3
|
}
|
|
4
4
|
function p(n) {
|
|
5
5
|
return n > 10 ? p(10) + p(n - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, n + 2);
|
|
6
6
|
}
|
|
7
|
-
const g = Object.prototype.toString, f = (n) => g.call(n),
|
|
7
|
+
const g = Object.prototype.toString, f = (n) => g.call(n), A = (...n) => console.log(
|
|
8
8
|
`%c ${n[0]} `,
|
|
9
9
|
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
10
10
|
n.slice(1).length > 0 ? n.slice(1) : ""
|
|
11
|
-
),
|
|
11
|
+
), E = (...n) => console.warn(...n), S = (...n) => console.error(...n), j = (n) => f(n) === "[object Map]", C = (n) => f(n) === "[object Set]", a = (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", x = (n) => u(n) && l(n.then) && l(n.catch), c = (n) => n == null, R = (n) => n === void 0, U = (n) => n === null;
|
|
12
12
|
function Z(n) {
|
|
13
13
|
return n != null;
|
|
14
14
|
}
|
|
15
15
|
function N(n) {
|
|
16
16
|
return typeof n == "boolean";
|
|
17
17
|
}
|
|
18
|
-
const d = Array.isArray,
|
|
19
|
-
function
|
|
18
|
+
const d = Array.isArray, b = (n, e) => Object.hasOwn(n, e), P = (n, e) => n !== e;
|
|
19
|
+
function y(n) {
|
|
20
20
|
const e = /* @__PURE__ */ new WeakMap();
|
|
21
21
|
function r(t) {
|
|
22
22
|
if (a(t))
|
|
@@ -35,23 +35,23 @@ function m(n) {
|
|
|
35
35
|
}
|
|
36
36
|
e.set(t, i);
|
|
37
37
|
for (const o in t)
|
|
38
|
-
|
|
38
|
+
b(t, o) && (i[o] = r(t[o]));
|
|
39
39
|
return i;
|
|
40
40
|
} else
|
|
41
41
|
return t;
|
|
42
42
|
}
|
|
43
43
|
return r(n);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return d(n) ?
|
|
45
|
+
function m(n, e, r) {
|
|
46
|
+
return d(n) ? O(n, e, r) : w(n, e, r);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function w(n, e, r) {
|
|
49
49
|
const t = s(e, r);
|
|
50
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]) ?
|
|
51
|
+
c(e[o]) ? t[o] = s(n[o], r) : t[o] = u(n[o]) && u(e[o]) ? m(n[o], e[o], r) : s(e[o], r);
|
|
52
52
|
}), t;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function O(n, e, r) {
|
|
55
55
|
if (d(e)) {
|
|
56
56
|
const t = s(e, r);
|
|
57
57
|
return t.push(...s(n, r)), t;
|
|
@@ -60,9 +60,9 @@ function $(n, e, r) {
|
|
|
60
60
|
}
|
|
61
61
|
function s(n, e) {
|
|
62
62
|
const { isDeepClone: r = !0 } = e || {};
|
|
63
|
-
return r ?
|
|
63
|
+
return r ? y(n) : n;
|
|
64
64
|
}
|
|
65
|
-
function F(n, e =
|
|
65
|
+
function F(n, e = 500) {
|
|
66
66
|
let r = null;
|
|
67
67
|
return function(...t) {
|
|
68
68
|
r && clearTimeout(r), r = setTimeout(() => {
|
|
@@ -70,10 +70,10 @@ function F(n, e = 1e3) {
|
|
|
70
70
|
}, e);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function T(n, e =
|
|
73
|
+
function T(n, e = 500) {
|
|
74
74
|
let r = null;
|
|
75
75
|
return function(...t) {
|
|
76
|
-
if (
|
|
76
|
+
if (c(r))
|
|
77
77
|
return r = Date.now(), n.apply(this, t);
|
|
78
78
|
{
|
|
79
79
|
const i = Date.now();
|
|
@@ -144,13 +144,13 @@ export {
|
|
|
144
144
|
z as compose,
|
|
145
145
|
L as composeRight,
|
|
146
146
|
F as debounce,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
y as deepClone,
|
|
148
|
+
m as deepMerge,
|
|
149
|
+
S as error,
|
|
150
|
+
$ as getRandomColor,
|
|
151
151
|
p as getRandomString,
|
|
152
152
|
P as hasChanged,
|
|
153
|
-
|
|
153
|
+
b as hasOwn,
|
|
154
154
|
d as isArray,
|
|
155
155
|
N as isBoolean,
|
|
156
156
|
J as isChineseOrEnglish,
|
|
@@ -162,27 +162,27 @@ export {
|
|
|
162
162
|
l as isFunction,
|
|
163
163
|
q as isLatitudeOrLongitude,
|
|
164
164
|
B as isLowerCase,
|
|
165
|
-
|
|
165
|
+
j as isMap,
|
|
166
166
|
_ as isMobilePhone,
|
|
167
|
-
|
|
167
|
+
U as isNull,
|
|
168
168
|
W as isNumber,
|
|
169
169
|
u as isObject,
|
|
170
170
|
k as isPositiveFloat,
|
|
171
171
|
X as isPositiveInt,
|
|
172
172
|
Y as isPositiveIntAndZero,
|
|
173
|
-
|
|
173
|
+
x as isPromise,
|
|
174
174
|
h as isRegExp,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
C as isSet,
|
|
176
|
+
M as isString,
|
|
177
|
+
D as isSymbol,
|
|
178
178
|
c as isUndef,
|
|
179
|
-
|
|
179
|
+
R as isUndefined,
|
|
180
180
|
K as isUpperCase,
|
|
181
181
|
Q as isUppercaseOrNumbersOrSpecial,
|
|
182
182
|
V as isUppercaseOrNumbersOrUnderline,
|
|
183
|
-
|
|
183
|
+
A as log,
|
|
184
184
|
g as objectToString,
|
|
185
185
|
T as throttle,
|
|
186
186
|
f as toTypeString,
|
|
187
|
-
|
|
187
|
+
E as warn
|
|
188
188
|
};
|