@lntvow/utils 2.1.9 → 2.1.11
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 +38 -4
- package/dist/index.mjs +170 -147
- package/package.json +3 -5
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=Object.prototype.toString,c=t=>h.call(t);let f=null;function S(t){d(t)&&(f=t)}const C=(t,...e)=>{const r=e.length===0?"":e.length===1?e[0]:e;console.log(`%c ${t} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",r),f&&f(t,r)},P=(...t)=>console.warn(...t),A=(...t)=>console.error(...t),I=t=>c(t)==="[object Map]",F=t=>c(t)==="[object Set]",b=t=>c(t)==="[object Date]",m=t=>c(t)==="[object RegExp]",d=t=>typeof t=="function",M=t=>typeof t=="number",O=t=>typeof t=="string",Z=t=>typeof t=="symbol",u=t=>t!==null&&typeof t=="object",j=t=>u(t)&&d(t.then)&&d(t.catch),s=t=>t==null,R=t=>t===void 0,U=t=>t===null,D=t=>t!=null,L=t=>typeof t=="boolean",l=Array.isArray,v=(t,e)=>Object.hasOwn(t,e),x=(t,e)=>t!==e;class $ extends Error{constructor(e){super(e),this.name="LntvowError"}}function T(t,e){throw new $(`[${t}] ${e}`)}function w(t,e){if(process.env.NODE_ENV!=="production"){const r=O(t)?new $(`[${t}] ${e}`):t;console.warn(r)}}function z(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function W(t,e={}){const{lowerCase:r=!0,upperCase:n=!0,number:i=!0}=e;r||n||i||w("getRandomString","lowerCase upperCase number 至少需要一个参数为true");let o="";r&&(o+="abcdefghijklmnopqrstuvwxyz"),n&&(o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"),i&&(o+="0123456789");let g="";for(let p=0;p<t;p++){const N=Math.floor(Math.random()*o.length);g+=o.charAt(N)}return g}function _(t=0,e=1e4){return Math.floor(Math.random()*(e-t+1))+Math.floor(t)}function y(t){const e=new WeakMap;function r(n){if(b(n))return new Date(n);if(m(n))return new RegExp(n);if(u(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)v(n,o)&&(i[o]=r(n[o]));return i}else return n}return r(t)}function E(t,e,r){return l(t)?K(t,e,r):B(t,e,r)}function B(t,e,r){const n=a(e,r);return Object.keys(t).forEach(o=>{s(e[o])?n[o]=a(t[o],r):n[o]=u(t[o])&&u(e[o])?E(t[o],e[o],r):a(e[o],r)}),n}function K(t,e,r){if(l(e)){const n=a(e,r);return n.push(...a(t,r)),n}else return a(t,r)}function a(t,e){const{isDeepClone:r=!0}=e||{};return r?y(t):t}function V(t,e=500){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,n)},e)}}function q(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 G(...t){return t.reduce((e,r)=>function(...n){return r(e(...n))})}function H(...t){return t.reduce((e,r)=>function(...n){return e(r(...n))})}function J(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 Q(t){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(t)}function X(t){return/^[A-Z]+$/.test(t)}function Y(t){return!s(t)&&/^[a-z]+$/.test(t)}function k(t){return/^\d+$/.test(t)}function tt(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function et(t){return t===""}function rt(t){return!s(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function nt(t){return!s(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function ot(t){return!s(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function it(t){return/^[\dA-Z_]+$/.test(t)}function st(t){return/^[1-9]\d*$/.test(t)}function at(t){return/^\d+$/.test(t)}function ut(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function ct(t){return Array.isArray(t)?t:[t]}function dt(t){return/^-?\d+$/.test(t)}function lt(t){return/^[1-9]\d*$/.test(t)}function ft(t){return/^-\d+$/.test(t)}function gt(t){return/^(0|[1-9]\d*)$/.test(t)}function pt(t){return/^(-[1-9]\d*|0)$/.test(t)}function ht(t){return/^-?\d+(\.\d+)?$/.test(t)}function bt(t){return/^(0\.\d+|[1-9]\d*(\.\d+)?)$/.test(t)}function mt(t){return/^-\d+(\.\d+)?$/.test(t)}function Ot(t){return/^\d+(\.\d+)?$/.test(t)}function vt(t){return/^(-\d+(\.\d+)?$)|(0(\.0+)?)$/.test(t)}exports.castArray=ct;exports.compose=G;exports.composeRight=H;exports.debounce=V;exports.debugWarn=w;exports.deepClone=y;exports.deepMerge=E;exports.error=A;exports.getRandomColor=z;exports.getRandomInteger=_;exports.getRandomString=W;exports.hasChanged=x;exports.hasOwn=v;exports.initLog=S;exports.isArray=l;exports.isBoolean=L;exports.isDate=b;exports.isDef=D;exports.isEmptyString=et;exports.isFloat=ht;exports.isFunction=d;exports.isInteger=dt;exports.isMap=I;exports.isNegativeFloat=mt;exports.isNegativeFloatOrZero=vt;exports.isNegativeInteger=ft;exports.isNegativeIntegerOrZero=pt;exports.isNull=U;exports.isNumber=M;exports.isObject=u;exports.isPositiveFloat=bt;exports.isPositiveFloatOrZero=Ot;exports.isPositiveInteger=lt;exports.isPositiveIntegerOrZero=gt;exports.isPromise=j;exports.isRegExp=m;exports.isSet=F;exports.isString=O;exports.isSymbol=Z;exports.isUndef=s;exports.isUndefined=R;exports.log=C;exports.objectToString=h;exports.throttle=q;exports.throwError=T;exports.toTypeString=c;exports.validatorChineseOrEnglish=nt;exports.validatorChineseOrEnglishOrNumber=rt;exports.validatorEmail=Q;exports.validatorLatitudeOrLongitude=tt;exports.validatorLowerCase=Y;exports.validatorMobilePhone=J;exports.validatorNumber=k;exports.validatorPositiveFloat=ut;exports.validatorPositiveInt=st;exports.validatorPositiveIntAndZero=at;exports.validatorUpperCase=X;exports.validatorUppercaseOrNumbersOrSpecial=ot;exports.validatorUppercaseOrNumbersOrUnderline=it;exports.warn=P;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export declare function composeRight(...fns: ((...args: any[]) => any)[]): (...a
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
|
|
26
26
|
|
|
27
|
+
export declare function debugWarn(err: Error): void;
|
|
28
|
+
|
|
29
|
+
export declare function debugWarn(scope: string, message: string): void;
|
|
30
|
+
|
|
27
31
|
/**
|
|
28
32
|
* @description 深拷贝
|
|
29
33
|
* @param target 拷贝对象
|
|
@@ -44,20 +48,48 @@ export declare const error: (...arg: unknown[]) => void;
|
|
|
44
48
|
|
|
45
49
|
/**
|
|
46
50
|
* @description 获取随机颜色
|
|
47
|
-
* @return
|
|
51
|
+
* @return 随机颜色
|
|
48
52
|
*
|
|
49
53
|
* @example getRandomColor() => '#f36a38'
|
|
50
54
|
* */
|
|
51
55
|
export declare function getRandomColor(): string;
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @description 获取整数范围内的随机数
|
|
59
|
+
* @param min 最小值 默认值为 0
|
|
60
|
+
* @param max 最大值 默认值为 10000
|
|
61
|
+
* @return 随机整数
|
|
62
|
+
*
|
|
63
|
+
* @example getRandomInteger() => ''
|
|
64
|
+
* */
|
|
65
|
+
export declare function getRandomInteger(min?: number, max?: number): number;
|
|
66
|
+
|
|
53
67
|
/**
|
|
54
68
|
* @description 获取随机字符串 大小写字母+数字
|
|
55
|
-
* @param
|
|
56
|
-
* @return
|
|
69
|
+
* @param length 返回字符串的长度
|
|
70
|
+
* @return 随机字符串
|
|
57
71
|
*
|
|
58
72
|
* @example getRandomString(20) => 'lZtJqMl0dyTO3WDGzFDO'
|
|
59
73
|
* */
|
|
60
|
-
export declare function getRandomString(
|
|
74
|
+
export declare function getRandomString(length: number, options?: GetRandomStringOptions): string;
|
|
75
|
+
|
|
76
|
+
declare interface GetRandomStringOptions {
|
|
77
|
+
/**
|
|
78
|
+
* @description 是否包含小写字母
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
lowerCase?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* @description 是否包含大写字母
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
upperCase?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* @description 是否包含数字
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
number?: boolean;
|
|
92
|
+
}
|
|
61
93
|
|
|
62
94
|
export declare const hasChanged: (oldValue: unknown, newValue: unknown) => boolean;
|
|
63
95
|
|
|
@@ -179,6 +211,8 @@ declare interface Options {
|
|
|
179
211
|
*/
|
|
180
212
|
export declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
|
|
181
213
|
|
|
214
|
+
export declare function throwError(scope: string, message: string): void;
|
|
215
|
+
|
|
182
216
|
export declare const toTypeString: (value: unknown) => string;
|
|
183
217
|
|
|
184
218
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,237 +1,260 @@
|
|
|
1
|
-
|
|
1
|
+
const b = Object.prototype.toString, f = (t) => b.call(t);
|
|
2
|
+
let d = null;
|
|
3
|
+
function S(t) {
|
|
4
|
+
a(t) && (d = t);
|
|
5
|
+
}
|
|
6
|
+
const j = (t, ...n) => {
|
|
7
|
+
const r = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
|
|
8
|
+
console.log(
|
|
9
|
+
`%c ${t} `,
|
|
10
|
+
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
11
|
+
r
|
|
12
|
+
), d && d(t, r);
|
|
13
|
+
}, Z = (...t) => console.warn(...t), x = (...t) => console.error(...t), F = (t) => f(t) === "[object Map]", I = (t) => f(t) === "[object Set]", m = (t) => f(t) === "[object Date]", w = (t) => f(t) === "[object RegExp]", a = (t) => typeof t == "function", P = (t) => typeof t == "number", O = (t) => typeof t == "string", D = (t) => typeof t == "symbol", u = (t) => t !== null && typeof t == "object", R = (t) => u(t) && a(t.then) && a(t.catch), c = (t) => t == null, v = (t) => t === void 0, L = (t) => t === null, U = (t) => t != null, T = (t) => typeof t == "boolean", l = Array.isArray, y = (t, n) => Object.hasOwn(t, n), z = (t, n) => t !== n;
|
|
14
|
+
class h extends Error {
|
|
15
|
+
constructor(n) {
|
|
16
|
+
super(n), this.name = "LntvowError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function _(t, n) {
|
|
20
|
+
throw new h(`[${t}] ${n}`);
|
|
21
|
+
}
|
|
22
|
+
function E(t, n) {
|
|
23
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24
|
+
const r = O(t) ? new h(`[${t}] ${n}`) : t;
|
|
25
|
+
console.warn(r);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function K() {
|
|
2
29
|
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
3
30
|
}
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
31
|
+
function W(t, n = {}) {
|
|
32
|
+
const { lowerCase: r = !0, upperCase: e = !0, number: i = !0 } = n;
|
|
33
|
+
r || e || i || E("getRandomString", "lowerCase upperCase number 至少需要一个参数为true");
|
|
34
|
+
let o = "";
|
|
35
|
+
r && (o += "abcdefghijklmnopqrstuvwxyz"), e && (o += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), i && (o += "0123456789");
|
|
36
|
+
let g = "";
|
|
37
|
+
for (let p = 0; p < t; p++) {
|
|
38
|
+
const $ = Math.floor(Math.random() * o.length);
|
|
39
|
+
g += o.charAt($);
|
|
10
40
|
}
|
|
11
|
-
return
|
|
41
|
+
return g;
|
|
12
42
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function j(t) {
|
|
16
|
-
a(t) && (f = t);
|
|
43
|
+
function B(t = 0, n = 1e4) {
|
|
44
|
+
return Math.floor(Math.random() * (n - t + 1)) + Math.floor(t);
|
|
17
45
|
}
|
|
18
|
-
|
|
19
|
-
const e = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
|
|
20
|
-
console.log(
|
|
21
|
-
`%c ${t} `,
|
|
22
|
-
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
23
|
-
e
|
|
24
|
-
), f && f(t, e);
|
|
25
|
-
}, S = (...t) => console.warn(...t), C = (...t) => console.error(...t), N = (t) => d(t) === "[object Map]", Z = (t) => d(t) === "[object Set]", p = (t) => d(t) === "[object Date]", h = (t) => d(t) === "[object RegExp]", a = (t) => typeof t == "function", F = (t) => typeof t == "number", M = (t) => typeof t == "string", P = (t) => typeof t == "symbol", u = (t) => t !== null && typeof t == "object", x = (t) => u(t) && a(t.then) && a(t.catch), c = (t) => t == null, I = (t) => t === void 0, D = (t) => t === null, R = (t) => t != null, U = (t) => typeof t == "boolean", l = Array.isArray, b = (t, n) => Object.hasOwn(t, n), L = (t, n) => t !== n;
|
|
26
|
-
function $(t) {
|
|
46
|
+
function A(t) {
|
|
27
47
|
const n = /* @__PURE__ */ new WeakMap();
|
|
28
|
-
function e
|
|
29
|
-
if (
|
|
30
|
-
return new Date(
|
|
31
|
-
if (
|
|
32
|
-
return new RegExp(
|
|
33
|
-
if (u(
|
|
34
|
-
if (n.has(
|
|
35
|
-
return n.get(
|
|
48
|
+
function r(e) {
|
|
49
|
+
if (m(e))
|
|
50
|
+
return new Date(e);
|
|
51
|
+
if (w(e))
|
|
52
|
+
return new RegExp(e);
|
|
53
|
+
if (u(e)) {
|
|
54
|
+
if (n.has(e))
|
|
55
|
+
return n.get(e);
|
|
36
56
|
let i = {};
|
|
37
|
-
if (l(
|
|
38
|
-
i = [], n.set(
|
|
39
|
-
for (let o = 0; o <
|
|
40
|
-
i[o] = e
|
|
57
|
+
if (l(e)) {
|
|
58
|
+
i = [], n.set(e, i);
|
|
59
|
+
for (let o = 0; o < e.length; o++)
|
|
60
|
+
i[o] = r(e[o]);
|
|
41
61
|
return i;
|
|
42
62
|
}
|
|
43
|
-
n.set(
|
|
44
|
-
for (const o in
|
|
45
|
-
|
|
63
|
+
n.set(e, i);
|
|
64
|
+
for (const o in e)
|
|
65
|
+
y(e, o) && (i[o] = r(e[o]));
|
|
46
66
|
return i;
|
|
47
67
|
} else
|
|
48
|
-
return
|
|
68
|
+
return e;
|
|
49
69
|
}
|
|
50
|
-
return
|
|
70
|
+
return r(t);
|
|
51
71
|
}
|
|
52
|
-
function
|
|
53
|
-
return l(t) ?
|
|
72
|
+
function C(t, n, r) {
|
|
73
|
+
return l(t) ? N(t, n, r) : M(t, n, r);
|
|
54
74
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
75
|
+
function M(t, n, r) {
|
|
76
|
+
const e = s(n, r);
|
|
57
77
|
return Object.keys(t).forEach((o) => {
|
|
58
|
-
c(n[o]) ?
|
|
59
|
-
}),
|
|
78
|
+
c(n[o]) ? e[o] = s(t[o], r) : e[o] = u(t[o]) && u(n[o]) ? C(t[o], n[o], r) : s(n[o], r);
|
|
79
|
+
}), e;
|
|
60
80
|
}
|
|
61
|
-
function
|
|
81
|
+
function N(t, n, r) {
|
|
62
82
|
if (l(n)) {
|
|
63
|
-
const
|
|
64
|
-
return
|
|
83
|
+
const e = s(n, r);
|
|
84
|
+
return e.push(...s(t, r)), e;
|
|
65
85
|
} else
|
|
66
|
-
return s(t,
|
|
86
|
+
return s(t, r);
|
|
67
87
|
}
|
|
68
88
|
function s(t, n) {
|
|
69
|
-
const { isDeepClone:
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
function
|
|
73
|
-
let
|
|
74
|
-
return function(...
|
|
75
|
-
|
|
76
|
-
t.apply(this,
|
|
89
|
+
const { isDeepClone: r = !0 } = n || {};
|
|
90
|
+
return r ? A(t) : t;
|
|
91
|
+
}
|
|
92
|
+
function V(t, n = 500) {
|
|
93
|
+
let r = null;
|
|
94
|
+
return function(...e) {
|
|
95
|
+
r && clearTimeout(r), r = setTimeout(() => {
|
|
96
|
+
t.apply(this, e);
|
|
77
97
|
}, n);
|
|
78
98
|
};
|
|
79
99
|
}
|
|
80
|
-
function
|
|
81
|
-
let
|
|
82
|
-
return function(...
|
|
83
|
-
if (c(
|
|
84
|
-
return
|
|
100
|
+
function q(t, n = 500) {
|
|
101
|
+
let r = null;
|
|
102
|
+
return function(...e) {
|
|
103
|
+
if (c(r))
|
|
104
|
+
return r = Date.now(), t.apply(this, e);
|
|
85
105
|
{
|
|
86
106
|
const i = Date.now();
|
|
87
|
-
if (i -
|
|
88
|
-
return
|
|
107
|
+
if (i - r >= n)
|
|
108
|
+
return r = i, t.apply(this, e);
|
|
89
109
|
}
|
|
90
110
|
};
|
|
91
111
|
}
|
|
92
|
-
function
|
|
93
|
-
return t.reduce((n,
|
|
94
|
-
return
|
|
112
|
+
function G(...t) {
|
|
113
|
+
return t.reduce((n, r) => function(...e) {
|
|
114
|
+
return r(n(...e));
|
|
95
115
|
});
|
|
96
116
|
}
|
|
97
|
-
function
|
|
98
|
-
return t.reduce((n,
|
|
99
|
-
return n(
|
|
117
|
+
function H(...t) {
|
|
118
|
+
return t.reduce((n, r) => function(...e) {
|
|
119
|
+
return n(r(...e));
|
|
100
120
|
});
|
|
101
121
|
}
|
|
102
|
-
function
|
|
122
|
+
function J(t) {
|
|
103
123
|
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(
|
|
104
124
|
t
|
|
105
125
|
);
|
|
106
126
|
}
|
|
107
|
-
function
|
|
127
|
+
function Q(t) {
|
|
108
128
|
return /^([\w-])+@([\w-])+(\.[\w-])+/.test(t);
|
|
109
129
|
}
|
|
110
|
-
function
|
|
130
|
+
function X(t) {
|
|
111
131
|
return /^[A-Z]+$/.test(t);
|
|
112
132
|
}
|
|
113
|
-
function
|
|
133
|
+
function Y(t) {
|
|
114
134
|
return !c(t) && /^[a-z]+$/.test(t);
|
|
115
135
|
}
|
|
116
|
-
function
|
|
136
|
+
function k(t) {
|
|
117
137
|
return /^\d+$/.test(t);
|
|
118
138
|
}
|
|
119
|
-
function
|
|
139
|
+
function tt(t) {
|
|
120
140
|
return /^-?\d{1,3}\.\d{6}$/.test(t);
|
|
121
141
|
}
|
|
122
|
-
function
|
|
142
|
+
function nt(t) {
|
|
123
143
|
return t === "";
|
|
124
144
|
}
|
|
125
|
-
function
|
|
145
|
+
function rt(t) {
|
|
126
146
|
return !c(t) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
|
|
127
147
|
}
|
|
128
|
-
function
|
|
148
|
+
function et(t) {
|
|
129
149
|
return !c(t) && /^[A-Za-z\u4E00-\u9FA5]+$/.test(t);
|
|
130
150
|
}
|
|
131
|
-
function
|
|
151
|
+
function ot(t) {
|
|
132
152
|
return !c(t) && /^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t);
|
|
133
153
|
}
|
|
134
|
-
function
|
|
154
|
+
function it(t) {
|
|
135
155
|
return /^[\dA-Z_]+$/.test(t);
|
|
136
156
|
}
|
|
137
|
-
function
|
|
157
|
+
function st(t) {
|
|
138
158
|
return /^[1-9]\d*$/.test(t);
|
|
139
159
|
}
|
|
140
|
-
function
|
|
160
|
+
function ct(t) {
|
|
141
161
|
return /^\d+$/.test(t);
|
|
142
162
|
}
|
|
143
|
-
function
|
|
163
|
+
function ut(t) {
|
|
144
164
|
return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t);
|
|
145
165
|
}
|
|
146
|
-
function
|
|
166
|
+
function ft(t) {
|
|
147
167
|
return Array.isArray(t) ? t : [t];
|
|
148
168
|
}
|
|
149
|
-
function
|
|
169
|
+
function dt(t) {
|
|
150
170
|
return /^-?\d+$/.test(t);
|
|
151
171
|
}
|
|
152
|
-
function
|
|
172
|
+
function at(t) {
|
|
153
173
|
return /^[1-9]\d*$/.test(t);
|
|
154
174
|
}
|
|
155
|
-
function
|
|
175
|
+
function lt(t) {
|
|
156
176
|
return /^-\d+$/.test(t);
|
|
157
177
|
}
|
|
158
|
-
function
|
|
178
|
+
function gt(t) {
|
|
159
179
|
return /^(0|[1-9]\d*)$/.test(t);
|
|
160
180
|
}
|
|
161
|
-
function
|
|
181
|
+
function pt(t) {
|
|
162
182
|
return /^(-[1-9]\d*|0)$/.test(t);
|
|
163
183
|
}
|
|
164
|
-
function
|
|
184
|
+
function ht(t) {
|
|
165
185
|
return /^-?\d+(\.\d+)?$/.test(t);
|
|
166
186
|
}
|
|
167
|
-
function
|
|
187
|
+
function $t(t) {
|
|
168
188
|
return /^(0\.\d+|[1-9]\d*(\.\d+)?)$/.test(t);
|
|
169
189
|
}
|
|
170
|
-
function
|
|
190
|
+
function bt(t) {
|
|
171
191
|
return /^-\d+(\.\d+)?$/.test(t);
|
|
172
192
|
}
|
|
173
|
-
function
|
|
193
|
+
function mt(t) {
|
|
174
194
|
return /^\d+(\.\d+)?$/.test(t);
|
|
175
195
|
}
|
|
176
|
-
function
|
|
196
|
+
function wt(t) {
|
|
177
197
|
return /^(-\d+(\.\d+)?$)|(0(\.0+)?)$/.test(t);
|
|
178
198
|
}
|
|
179
199
|
export {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
C as
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
200
|
+
ft as castArray,
|
|
201
|
+
G as compose,
|
|
202
|
+
H as composeRight,
|
|
203
|
+
V as debounce,
|
|
204
|
+
E as debugWarn,
|
|
205
|
+
A as deepClone,
|
|
206
|
+
C as deepMerge,
|
|
207
|
+
x as error,
|
|
208
|
+
K as getRandomColor,
|
|
209
|
+
B as getRandomInteger,
|
|
210
|
+
W as getRandomString,
|
|
211
|
+
z as hasChanged,
|
|
212
|
+
y as hasOwn,
|
|
213
|
+
S as initLog,
|
|
192
214
|
l as isArray,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
215
|
+
T as isBoolean,
|
|
216
|
+
m as isDate,
|
|
217
|
+
U as isDef,
|
|
218
|
+
nt as isEmptyString,
|
|
219
|
+
ht as isFloat,
|
|
198
220
|
a as isFunction,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
221
|
+
dt as isInteger,
|
|
222
|
+
F as isMap,
|
|
223
|
+
bt as isNegativeFloat,
|
|
224
|
+
wt as isNegativeFloatOrZero,
|
|
225
|
+
lt as isNegativeInteger,
|
|
226
|
+
pt as isNegativeIntegerOrZero,
|
|
227
|
+
L as isNull,
|
|
228
|
+
P as isNumber,
|
|
207
229
|
u as isObject,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
230
|
+
$t as isPositiveFloat,
|
|
231
|
+
mt as isPositiveFloatOrZero,
|
|
232
|
+
at as isPositiveInteger,
|
|
233
|
+
gt as isPositiveIntegerOrZero,
|
|
234
|
+
R as isPromise,
|
|
235
|
+
w as isRegExp,
|
|
236
|
+
I as isSet,
|
|
237
|
+
O as isString,
|
|
238
|
+
D as isSymbol,
|
|
217
239
|
c as isUndef,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
X as
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
v as isUndefined,
|
|
241
|
+
j as log,
|
|
242
|
+
b as objectToString,
|
|
243
|
+
q as throttle,
|
|
244
|
+
_ as throwError,
|
|
245
|
+
f as toTypeString,
|
|
246
|
+
et as validatorChineseOrEnglish,
|
|
247
|
+
rt as validatorChineseOrEnglishOrNumber,
|
|
248
|
+
Q as validatorEmail,
|
|
249
|
+
tt as validatorLatitudeOrLongitude,
|
|
250
|
+
Y as validatorLowerCase,
|
|
251
|
+
J as validatorMobilePhone,
|
|
252
|
+
k as validatorNumber,
|
|
253
|
+
ut as validatorPositiveFloat,
|
|
254
|
+
st as validatorPositiveInt,
|
|
255
|
+
ct as validatorPositiveIntAndZero,
|
|
256
|
+
X as validatorUpperCase,
|
|
257
|
+
ot as validatorUppercaseOrNumbersOrSpecial,
|
|
258
|
+
it as validatorUppercaseOrNumbersOrUnderline,
|
|
259
|
+
Z as warn
|
|
237
260
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/utils",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "工具库",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@commitlint/cli": "^18.4.3",
|
|
16
16
|
"@commitlint/config-conventional": "^18.4.3",
|
|
17
|
-
"@lntvow/eslint-config": "^8.3.
|
|
17
|
+
"@lntvow/eslint-config": "^8.3.5",
|
|
18
18
|
"bumpp": "^9.2.1",
|
|
19
19
|
"commitizen": "^4.3.0",
|
|
20
20
|
"cz-conventional-changelog": "^3.3.0",
|
|
21
21
|
"deepmerge": "^4.3.1",
|
|
22
|
+
"husky": "^8.0.3",
|
|
22
23
|
"lint-staged": "^15.2.0",
|
|
23
24
|
"typescript": "^5.3.3",
|
|
24
25
|
"vite": "^5.0.8",
|
|
@@ -33,9 +34,6 @@
|
|
|
33
34
|
"prettier --write"
|
|
34
35
|
]
|
|
35
36
|
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"vconsole": "^3.15.1"
|
|
38
|
-
},
|
|
39
37
|
"scripts": {
|
|
40
38
|
"dev": "vite",
|
|
41
39
|
"test": "vitest",
|