@lntvow/utils 2.1.16 → 2.2.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 +69 -4
- package/dist/index.mjs +188 -156
- 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 N(...t){return t.reduce((e,n)=>function(...r){return n(e(...r))})}function I(...t){return t.reduce((e,n)=>function(...r){return e(n(...r))})}function P(t,e=500){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{t.apply(this,r)},e)}}const m=Object.prototype.toString,d=t=>m.call(t);let h=null;function A(t){g(t)&&(h=t)}const F=(t,...e)=>{const n=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;",n),h&&h(t,n)},M=(...t)=>console.warn(...t),R=(...t)=>console.error(...t),Z=t=>d(t)==="[object Map]",j=t=>d(t)==="[object Set]",b=t=>d(t)==="[object Date]",O=t=>d(t)==="[object RegExp]",g=t=>typeof t=="function",U=t=>typeof t=="number",$=t=>typeof t=="string",x=t=>typeof t=="symbol",u=t=>t!==null&&typeof t=="object",D=t=>u(t)&&g(t.then)&&g(t.catch),s=t=>t==null,L=t=>t===void 0,T=t=>t===null,W=t=>t!=null,q=t=>typeof t=="boolean",p=Array.isArray,v=(t,e)=>Object.hasOwn(t,e),z=(t,e)=>t!==e;function y(t){const e=new WeakMap;function n(r){if(b(r))return new Date(r);if(O(r))return new RegExp(r);if(u(r)){if(e.has(r))return e.get(r);let i={};if(p(r)){i=[],e.set(r,i);for(let o=0;o<r.length;o++)i[o]=n(r[o]);return i}e.set(r,i);for(const o in r)v(r,o)&&(i[o]=n(r[o]));return i}else return r}return n(t)}function l(t,e,n){return p(t)?_(t,e,n):B(t,e,n)}function B(t,e,n){const r=c(e,n);return Object.keys(t).forEach(o=>{s(e[o])?r[o]=c(t[o],n):r[o]=u(t[o])&&u(e[o])?l(t[o],e[o],n):c(e[o],n)}),r}function _(t,e,n){if(p(e)){const r=c(e,n);return r.push(...c(t,n)),r}else return c(t,n)}function c(t,e){const{isDeepClone:n=!0}=e||{};return n?y(t):t}class w extends Error{constructor(e){super(e),this.name="LntvowError"}}function C(t,e){throw new w(`[${t}] ${e}`)}function K(t,e){if(process.env.NODE_ENV!=="production"){const n=$(t)?new w(`[${t}] ${e}`):t;console.warn(n)}}function Q(t,e){const{decode:n}=l({decode:!0},e||{}),r={};t.startsWith("?")&&(t=t.slice(1)),t.includes("?")&&(t=t.slice(t.indexOf("?")+1));const i=t.split("&").filter(Boolean);for(const o of i){const[f,a]=o.split("=");r[f]=n?decodeURIComponent(a):a}return r}function E(t,e){const{encode:n}=l({encode:!0},e||{}),r=[];for(const i in t){const o=t[i];r.push(`${i}=${n?encodeURIComponent(o):o}`)}return r.join("&")}function V(t,e,n){const r=l({encode:!0},n||{}),i=E(e,r);return t.includes("?")?t.endsWith("?")||t.endsWith("&")?`${t}${i}`:`${t}&${i}`:`${t}?${i}`}const G={parse:Q,stringify:E,appendQueryString:V};function H(t,e=500){let n=null;return function(...r){if(s(n))return n=Date.now(),t.apply(this,r);{const i=Date.now();if(i-n>=e)return n=i,t.apply(this,r)}}}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 X(t){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(t)}function Y(t){return/^[A-Z]+$/.test(t)}function k(t){return!s(t)&&/^[a-z]+$/.test(t)}function tt(t){return/^\d+$/.test(t)}function et(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function nt(t){return t===""}function rt(t){return!s(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function ot(t){return!s(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function it(t){return!s(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function st(t){return/^[\dA-Z_]+$/.test(t)}function ct(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 dt(t){return Array.isArray(t)?t:[t]}function lt(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function ft(t=0,e=1e6){return Math.random()*(e-t)+t}function gt(t=0,e=1e6){return Math.floor(Math.random()*(e-t+1))+Math.floor(t)}function pt(t,e={}){const{lowerCase:n=!0,upperCase:r=!0,number:i=!0}=e;n||r||i||C("getRandomString","lowerCase upperCase number 至少需要一个参数为true");let o="";n&&(o+="abcdefghijklmnopqrstuvwxyz"),r&&(o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"),i&&(o+="0123456789");let f="";for(let a=0;a<t;a++){const S=Math.floor(Math.random()*o.length);f+=o.charAt(S)}return f}function ht(t){return/^-?(0|[1-9]\d*)$/.test(t)}function mt(t){return/^[1-9]\d*$/.test(t)}function bt(t){return/^(0|[1-9]\d*)$/.test(t)}function Ot(t){return/^-([1-9]\d*)$/.test(t)}function $t(t){return/^(0|-(0|[1-9]\d*))$/.test(t)}function vt(t,e){return/^-?\d+(\.\d+)?$/.test(t)}function yt(t){return/^(0\.\d+|[1-9]\d*(\.\d+)?)$/.test(t)}function wt(t){return/^-\d+(\.\d+)?$/.test(t)}function Ct(t){return/^\d+(\.\d+)?$/.test(t)}function Et(t){return/^(-\d+(\.\d+)?$)|(0(\.0+)?)$/.test(t)}exports.castArray=dt;exports.compose=N;exports.composeRight=I;exports.debounce=P;exports.debugWarn=K;exports.deepClone=y;exports.deepMerge=l;exports.error=R;exports.getRandomColor=lt;exports.getRandomFloat=ft;exports.getRandomInteger=gt;exports.getRandomString=pt;exports.hasChanged=z;exports.hasOwn=v;exports.initLog=A;exports.isArray=p;exports.isBoolean=q;exports.isDate=b;exports.isDef=W;exports.isEmptyString=nt;exports.isFloat=vt;exports.isFunction=g;exports.isInteger=ht;exports.isMap=Z;exports.isNegativeFloat=wt;exports.isNegativeFloatOrZero=Et;exports.isNegativeInteger=Ot;exports.isNegativeIntegerOrZero=$t;exports.isNull=T;exports.isNumber=U;exports.isObject=u;exports.isPositiveFloat=yt;exports.isPositiveFloatOrZero=Ct;exports.isPositiveInteger=mt;exports.isPositiveIntegerOrZero=bt;exports.isPromise=D;exports.isRegExp=O;exports.isSet=j;exports.isString=$;exports.isSymbol=x;exports.isUndef=s;exports.isUndefined=L;exports.log=F;exports.objectToString=m;exports.qs=G;exports.throttle=H;exports.throwError=C;exports.toTypeString=d;exports.validatorChineseOrEnglish=ot;exports.validatorChineseOrEnglishOrNumber=rt;exports.validatorEmail=X;exports.validatorLatitudeOrLongitude=et;exports.validatorLowerCase=k;exports.validatorMobilePhone=J;exports.validatorNumber=tt;exports.validatorPositiveFloat=ut;exports.validatorPositiveInt=ct;exports.validatorPositiveIntAndZero=at;exports.validatorUpperCase=Y;exports.validatorUppercaseOrNumbersOrSpecial=it;exports.validatorUppercaseOrNumbersOrUnderline=st;exports.warn=M;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export declare type AnyObj = Record<string, any>;
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @description url追加查询字符串
|
|
5
|
+
* @param url url
|
|
6
|
+
* @param obj 查询字符串对象
|
|
7
|
+
* @return 追加后的url
|
|
8
|
+
* @example
|
|
9
|
+
* appendQueryString('https://www.baidu.com', { a: '1', b: '2' }) => 'https://www.baidu.com?a=1&b=2'
|
|
10
|
+
* appendQueryString('/pages/index?id=10', { test:'23' }) => '/pages/index?id=10&test=23'
|
|
11
|
+
*/
|
|
12
|
+
declare function appendQueryString(url: string, obj: AnyObj, options?: StringifyOptions): string;
|
|
13
|
+
|
|
14
|
+
export declare type Arrayable<T> = T | T[];
|
|
15
|
+
|
|
16
|
+
export declare function castArray<T>(target: T | T[]): T[];
|
|
4
17
|
|
|
5
18
|
/**
|
|
6
19
|
* @description compose
|
|
@@ -46,6 +59,14 @@ export declare function deepMerge(template: AnyObj, source: AnyObj, options?: Op
|
|
|
46
59
|
|
|
47
60
|
export declare const error: (...arg: unknown[]) => void;
|
|
48
61
|
|
|
62
|
+
export declare interface FloatOptions {
|
|
63
|
+
/**
|
|
64
|
+
* @description 是否包括整数
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
integer?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
/**
|
|
50
71
|
* @description 获取随机颜色
|
|
51
72
|
* @return 随机颜色
|
|
@@ -122,9 +143,8 @@ export declare function isEmptyString(value: string): boolean;
|
|
|
122
143
|
|
|
123
144
|
/**
|
|
124
145
|
* @description 校验是否为浮点数
|
|
125
|
-
* @returns 如果是浮点数包括整数返回 true,否则返回 false
|
|
126
146
|
*/
|
|
127
|
-
export declare function isFloat(val: string): boolean;
|
|
147
|
+
export declare function isFloat(val: string, floatOptions?: FloatOptions): boolean;
|
|
128
148
|
|
|
129
149
|
export declare const isFunction: (val: unknown) => val is Function;
|
|
130
150
|
|
|
@@ -163,7 +183,6 @@ export declare const isObject: (val: unknown) => val is Record<any, any>;
|
|
|
163
183
|
|
|
164
184
|
/**
|
|
165
185
|
* @description 校验是否为大于零的浮点数
|
|
166
|
-
* @returns 如果是大于零的浮点数返回 true,否则返回 false
|
|
167
186
|
*/
|
|
168
187
|
export declare function isPositiveFloat(val: string): boolean;
|
|
169
188
|
|
|
@@ -208,6 +227,52 @@ declare interface Options {
|
|
|
208
227
|
isDeepClone: boolean;
|
|
209
228
|
}
|
|
210
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @description 解析查询字符串
|
|
232
|
+
* @param str 转换的字符串
|
|
233
|
+
* @return 转换后的对象
|
|
234
|
+
* @example
|
|
235
|
+
* parse('a=1&b=2') => { a: '1', b: '2' }
|
|
236
|
+
* parse('?a=1&b=2') => { a: '1', b: '2' }
|
|
237
|
+
* parse('&a=1&b=2') => { a: '1', b: '2' }
|
|
238
|
+
* parse('from=%E4%B8%AD%E5%9B%BD') => { from: '中国' }
|
|
239
|
+
* parse('from=%E4%B8%AD%E5%9B%BD', { decode: false }) => { from: '%E4%B8%AD%E5%9B%BD' }
|
|
240
|
+
*/
|
|
241
|
+
declare function parse(str: string, options?: ParseOptions): Record<string, string>;
|
|
242
|
+
|
|
243
|
+
export declare interface ParseOptions {
|
|
244
|
+
/**
|
|
245
|
+
* @description 是否解码
|
|
246
|
+
* @default true
|
|
247
|
+
*/
|
|
248
|
+
decode?: boolean;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export declare const qs: {
|
|
252
|
+
parse: typeof parse;
|
|
253
|
+
stringify: typeof stringify;
|
|
254
|
+
appendQueryString: typeof appendQueryString;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
*@description 转换对象为查询字符串
|
|
259
|
+
* @param obj 转换的对象
|
|
260
|
+
* @return 转换后的字符串
|
|
261
|
+
* @example
|
|
262
|
+
* stringify({ a: '1', b: '2' }) => 'a=1&b=2'
|
|
263
|
+
* stringify({ from: '中国' }) => 'from=%E4%B8%AD%E5%9B%BD'
|
|
264
|
+
* stringify({ from: '中国' }, { encode: false }) => 'from=中国'
|
|
265
|
+
*/
|
|
266
|
+
declare function stringify(obj: Record<string, any>, options?: StringifyOptions): string;
|
|
267
|
+
|
|
268
|
+
export declare interface StringifyOptions {
|
|
269
|
+
/**
|
|
270
|
+
* @description 是否编码
|
|
271
|
+
* @default true
|
|
272
|
+
*/
|
|
273
|
+
encode?: boolean;
|
|
274
|
+
}
|
|
275
|
+
|
|
211
276
|
/**
|
|
212
277
|
* @description 节流函数
|
|
213
278
|
* @param target 目标函数
|
package/dist/index.mjs
CHANGED
|
@@ -1,128 +1,134 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return Math.random() * (n - t) + t;
|
|
1
|
+
function R(...t) {
|
|
2
|
+
return t.reduce((n, e) => function(...r) {
|
|
3
|
+
return e(n(...r));
|
|
4
|
+
});
|
|
6
5
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
6
|
+
function x(...t) {
|
|
7
|
+
return t.reduce((n, e) => function(...r) {
|
|
8
|
+
return n(e(...r));
|
|
9
|
+
});
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const $ = Math.floor(Math.random() * o.length);
|
|
18
|
-
g += o.charAt($);
|
|
19
|
-
}
|
|
20
|
-
return g;
|
|
11
|
+
function F(t, n = 500) {
|
|
12
|
+
let e = null;
|
|
13
|
+
return function(...r) {
|
|
14
|
+
e && clearTimeout(e), e = setTimeout(() => {
|
|
15
|
+
t.apply(this, r);
|
|
16
|
+
}, n);
|
|
17
|
+
};
|
|
21
18
|
}
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
function
|
|
25
|
-
|
|
19
|
+
const w = Object.prototype.toString, a = (t) => w.call(t);
|
|
20
|
+
let p = null;
|
|
21
|
+
function Z(t) {
|
|
22
|
+
g(t) && (p = t);
|
|
26
23
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
24
|
+
const P = (t, ...n) => {
|
|
25
|
+
const e = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
|
|
29
26
|
console.log(
|
|
30
27
|
`%c ${t} `,
|
|
31
28
|
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
32
|
-
|
|
33
|
-
),
|
|
34
|
-
},
|
|
35
|
-
class h extends Error {
|
|
36
|
-
constructor(n) {
|
|
37
|
-
super(n), this.name = "LntvowError";
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function E(t, n) {
|
|
41
|
-
throw new h(`[${t}] ${n}`);
|
|
42
|
-
}
|
|
43
|
-
function V(t, n) {
|
|
44
|
-
if (process.env.NODE_ENV !== "production") {
|
|
45
|
-
const r = O(t) ? new h(`[${t}] ${n}`) : t;
|
|
46
|
-
console.warn(r);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
29
|
+
e
|
|
30
|
+
), p && p(t, e);
|
|
31
|
+
}, v = (...t) => console.warn(...t), D = (...t) => console.error(...t), U = (t) => a(t) === "[object Map]", L = (t) => a(t) === "[object Set]", y = (t) => a(t) === "[object Date]", O = (t) => a(t) === "[object RegExp]", g = (t) => typeof t == "function", W = (t) => typeof t == "number", E = (t) => typeof t == "string", T = (t) => typeof t == "symbol", f = (t) => t !== null && typeof t == "object", z = (t) => f(t) && g(t.then) && g(t.catch), c = (t) => t == null, _ = (t) => t === void 0, q = (t) => t === null, B = (t) => t != null, K = (t) => typeof t == "boolean", h = Array.isArray, C = (t, n) => Object.hasOwn(t, n), Q = (t, n) => t !== n;
|
|
49
32
|
function A(t) {
|
|
50
33
|
const n = /* @__PURE__ */ new WeakMap();
|
|
51
|
-
function r
|
|
52
|
-
if (
|
|
53
|
-
return new Date(
|
|
54
|
-
if (
|
|
55
|
-
return new RegExp(
|
|
56
|
-
if (
|
|
57
|
-
if (n.has(
|
|
58
|
-
return n.get(
|
|
34
|
+
function e(r) {
|
|
35
|
+
if (y(r))
|
|
36
|
+
return new Date(r);
|
|
37
|
+
if (O(r))
|
|
38
|
+
return new RegExp(r);
|
|
39
|
+
if (f(r)) {
|
|
40
|
+
if (n.has(r))
|
|
41
|
+
return n.get(r);
|
|
59
42
|
let i = {};
|
|
60
|
-
if (
|
|
61
|
-
i = [], n.set(
|
|
62
|
-
for (let o = 0; o <
|
|
63
|
-
i[o] = r
|
|
43
|
+
if (h(r)) {
|
|
44
|
+
i = [], n.set(r, i);
|
|
45
|
+
for (let o = 0; o < r.length; o++)
|
|
46
|
+
i[o] = e(r[o]);
|
|
64
47
|
return i;
|
|
65
48
|
}
|
|
66
|
-
n.set(
|
|
67
|
-
for (const o in
|
|
68
|
-
|
|
49
|
+
n.set(r, i);
|
|
50
|
+
for (const o in r)
|
|
51
|
+
C(r, o) && (i[o] = e(r[o]));
|
|
69
52
|
return i;
|
|
70
53
|
} else
|
|
71
|
-
return
|
|
54
|
+
return r;
|
|
72
55
|
}
|
|
73
|
-
return
|
|
56
|
+
return e(t);
|
|
74
57
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
58
|
+
function l(t, n, e) {
|
|
59
|
+
return h(t) ? S(t, n, e) : M(t, n, e);
|
|
77
60
|
}
|
|
78
|
-
function M(t, n,
|
|
79
|
-
const
|
|
61
|
+
function M(t, n, e) {
|
|
62
|
+
const r = s(n, e);
|
|
80
63
|
return Object.keys(t).forEach((o) => {
|
|
81
|
-
c(n[o]) ?
|
|
82
|
-
}),
|
|
64
|
+
c(n[o]) ? r[o] = s(t[o], e) : r[o] = f(t[o]) && f(n[o]) ? l(t[o], n[o], e) : s(n[o], e);
|
|
65
|
+
}), r;
|
|
83
66
|
}
|
|
84
|
-
function
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
return
|
|
67
|
+
function S(t, n, e) {
|
|
68
|
+
if (h(n)) {
|
|
69
|
+
const r = s(n, e);
|
|
70
|
+
return r.push(...s(t, e)), r;
|
|
88
71
|
} else
|
|
89
|
-
return s(t,
|
|
72
|
+
return s(t, e);
|
|
90
73
|
}
|
|
91
74
|
function s(t, n) {
|
|
92
|
-
const { isDeepClone:
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
75
|
+
const { isDeepClone: e = !0 } = n || {};
|
|
76
|
+
return e ? A(t) : t;
|
|
77
|
+
}
|
|
78
|
+
class $ extends Error {
|
|
79
|
+
constructor(n) {
|
|
80
|
+
super(n), this.name = "LntvowError";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function N(t, n) {
|
|
84
|
+
throw new $(`[${t}] ${n}`);
|
|
85
|
+
}
|
|
86
|
+
function V(t, n) {
|
|
87
|
+
if (process.env.NODE_ENV !== "production") {
|
|
88
|
+
const e = E(t) ? new $(`[${t}] ${n}`) : t;
|
|
89
|
+
console.warn(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function j(t, n) {
|
|
93
|
+
const { decode: e } = l({ decode: !0 }, n || {}), r = {};
|
|
94
|
+
t.startsWith("?") && (t = t.slice(1)), t.includes("?") && (t = t.slice(t.indexOf("?") + 1));
|
|
95
|
+
const i = t.split("&").filter(Boolean);
|
|
96
|
+
for (const o of i) {
|
|
97
|
+
const [d, u] = o.split("=");
|
|
98
|
+
r[d] = e ? decodeURIComponent(u) : u;
|
|
99
|
+
}
|
|
100
|
+
return r;
|
|
101
|
+
}
|
|
102
|
+
function b(t, n) {
|
|
103
|
+
const { encode: e } = l({ encode: !0 }, n || {}), r = [];
|
|
104
|
+
for (const i in t) {
|
|
105
|
+
const o = t[i];
|
|
106
|
+
r.push(`${i}=${e ? encodeURIComponent(o) : o}`);
|
|
107
|
+
}
|
|
108
|
+
return r.join("&");
|
|
102
109
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
function I(t, n, e) {
|
|
111
|
+
const r = l({ encode: !0 }, e || {}), i = b(n, r);
|
|
112
|
+
return t.includes("?") ? t.endsWith("?") || t.endsWith("&") ? `${t}${i}` : `${t}&${i}` : `${t}?${i}`;
|
|
113
|
+
}
|
|
114
|
+
const G = {
|
|
115
|
+
parse: j,
|
|
116
|
+
stringify: b,
|
|
117
|
+
appendQueryString: I
|
|
118
|
+
};
|
|
119
|
+
function H(t, n = 500) {
|
|
120
|
+
let e = null;
|
|
121
|
+
return function(...r) {
|
|
122
|
+
if (c(e))
|
|
123
|
+
return e = Date.now(), t.apply(this, r);
|
|
108
124
|
{
|
|
109
125
|
const i = Date.now();
|
|
110
|
-
if (i -
|
|
111
|
-
return
|
|
126
|
+
if (i - e >= n)
|
|
127
|
+
return e = i, t.apply(this, r);
|
|
112
128
|
}
|
|
113
129
|
};
|
|
114
130
|
}
|
|
115
|
-
function
|
|
116
|
-
return t.reduce((n, r) => function(...e) {
|
|
117
|
-
return r(n(...e));
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
function J(...t) {
|
|
121
|
-
return t.reduce((n, r) => function(...e) {
|
|
122
|
-
return n(r(...e));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function Q(t) {
|
|
131
|
+
function J(t) {
|
|
126
132
|
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(
|
|
127
133
|
t
|
|
128
134
|
);
|
|
@@ -142,10 +148,10 @@ function tt(t) {
|
|
|
142
148
|
function nt(t) {
|
|
143
149
|
return /^-?\d{1,3}\.\d{6}$/.test(t);
|
|
144
150
|
}
|
|
145
|
-
function
|
|
151
|
+
function et(t) {
|
|
146
152
|
return t === "";
|
|
147
153
|
}
|
|
148
|
-
function
|
|
154
|
+
function rt(t) {
|
|
149
155
|
return !c(t) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
|
|
150
156
|
}
|
|
151
157
|
function ot(t) {
|
|
@@ -163,98 +169,124 @@ function ct(t) {
|
|
|
163
169
|
function ut(t) {
|
|
164
170
|
return /^\d+$/.test(t);
|
|
165
171
|
}
|
|
166
|
-
function
|
|
172
|
+
function dt(t) {
|
|
167
173
|
return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t);
|
|
168
174
|
}
|
|
169
|
-
function
|
|
175
|
+
function ft(t) {
|
|
176
|
+
return Array.isArray(t) ? t : [t];
|
|
177
|
+
}
|
|
178
|
+
function at() {
|
|
179
|
+
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
180
|
+
}
|
|
181
|
+
function lt(t = 0, n = 1e6) {
|
|
182
|
+
return Math.random() * (n - t) + t;
|
|
183
|
+
}
|
|
184
|
+
function pt(t = 0, n = 1e6) {
|
|
185
|
+
return Math.floor(Math.random() * (n - t + 1)) + Math.floor(t);
|
|
186
|
+
}
|
|
187
|
+
function gt(t, n = {}) {
|
|
188
|
+
const { lowerCase: e = !0, upperCase: r = !0, number: i = !0 } = n;
|
|
189
|
+
e || r || i || N("getRandomString", "lowerCase upperCase number 至少需要一个参数为true");
|
|
190
|
+
let o = "";
|
|
191
|
+
e && (o += "abcdefghijklmnopqrstuvwxyz"), r && (o += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), i && (o += "0123456789");
|
|
192
|
+
let d = "";
|
|
193
|
+
for (let u = 0; u < t; u++) {
|
|
194
|
+
const m = Math.floor(Math.random() * o.length);
|
|
195
|
+
d += o.charAt(m);
|
|
196
|
+
}
|
|
197
|
+
return d;
|
|
198
|
+
}
|
|
199
|
+
function ht(t) {
|
|
170
200
|
return /^-?(0|[1-9]\d*)$/.test(t);
|
|
171
201
|
}
|
|
172
|
-
function
|
|
202
|
+
function $t(t) {
|
|
173
203
|
return /^[1-9]\d*$/.test(t);
|
|
174
204
|
}
|
|
175
|
-
function
|
|
205
|
+
function bt(t) {
|
|
176
206
|
return /^(0|[1-9]\d*)$/.test(t);
|
|
177
207
|
}
|
|
178
|
-
function
|
|
208
|
+
function mt(t) {
|
|
179
209
|
return /^-([1-9]\d*)$/.test(t);
|
|
180
210
|
}
|
|
181
|
-
function
|
|
211
|
+
function wt(t) {
|
|
182
212
|
return /^(0|-(0|[1-9]\d*))$/.test(t);
|
|
183
213
|
}
|
|
184
|
-
function
|
|
214
|
+
function yt(t, n) {
|
|
185
215
|
return /^-?\d+(\.\d+)?$/.test(t);
|
|
186
216
|
}
|
|
187
|
-
function
|
|
217
|
+
function Ot(t) {
|
|
188
218
|
return /^(0\.\d+|[1-9]\d*(\.\d+)?)$/.test(t);
|
|
189
219
|
}
|
|
190
|
-
function
|
|
220
|
+
function Et(t) {
|
|
191
221
|
return /^-\d+(\.\d+)?$/.test(t);
|
|
192
222
|
}
|
|
193
|
-
function
|
|
223
|
+
function Ct(t) {
|
|
194
224
|
return /^\d+(\.\d+)?$/.test(t);
|
|
195
225
|
}
|
|
196
|
-
function
|
|
226
|
+
function At(t) {
|
|
197
227
|
return /^(-\d+(\.\d+)?$)|(0(\.0+)?)$/.test(t);
|
|
198
228
|
}
|
|
199
229
|
export {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
230
|
+
ft as castArray,
|
|
231
|
+
R as compose,
|
|
232
|
+
x as composeRight,
|
|
233
|
+
F as debounce,
|
|
204
234
|
V as debugWarn,
|
|
205
235
|
A as deepClone,
|
|
206
|
-
|
|
236
|
+
l as deepMerge,
|
|
207
237
|
D as error,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
at as getRandomColor,
|
|
239
|
+
lt as getRandomFloat,
|
|
240
|
+
pt as getRandomInteger,
|
|
241
|
+
gt as getRandomString,
|
|
242
|
+
Q as hasChanged,
|
|
243
|
+
C as hasOwn,
|
|
244
|
+
Z as initLog,
|
|
245
|
+
h as isArray,
|
|
246
|
+
K as isBoolean,
|
|
247
|
+
y as isDate,
|
|
248
|
+
B as isDef,
|
|
249
|
+
et as isEmptyString,
|
|
250
|
+
yt as isFloat,
|
|
251
|
+
g as isFunction,
|
|
252
|
+
ht as isInteger,
|
|
253
|
+
U as isMap,
|
|
254
|
+
Et as isNegativeFloat,
|
|
255
|
+
At as isNegativeFloatOrZero,
|
|
256
|
+
mt as isNegativeInteger,
|
|
257
|
+
wt as isNegativeIntegerOrZero,
|
|
258
|
+
q as isNull,
|
|
259
|
+
W as isNumber,
|
|
260
|
+
f as isObject,
|
|
261
|
+
Ot as isPositiveFloat,
|
|
262
|
+
Ct as isPositiveFloatOrZero,
|
|
263
|
+
$t as isPositiveInteger,
|
|
264
|
+
bt as isPositiveIntegerOrZero,
|
|
265
|
+
z as isPromise,
|
|
266
|
+
O as isRegExp,
|
|
267
|
+
L as isSet,
|
|
268
|
+
E as isString,
|
|
269
|
+
T as isSymbol,
|
|
239
270
|
c as isUndef,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
G as
|
|
244
|
-
|
|
245
|
-
|
|
271
|
+
_ as isUndefined,
|
|
272
|
+
P as log,
|
|
273
|
+
w as objectToString,
|
|
274
|
+
G as qs,
|
|
275
|
+
H as throttle,
|
|
276
|
+
N as throwError,
|
|
277
|
+
a as toTypeString,
|
|
246
278
|
ot as validatorChineseOrEnglish,
|
|
247
|
-
|
|
279
|
+
rt as validatorChineseOrEnglishOrNumber,
|
|
248
280
|
X as validatorEmail,
|
|
249
281
|
nt as validatorLatitudeOrLongitude,
|
|
250
282
|
k as validatorLowerCase,
|
|
251
|
-
|
|
283
|
+
J as validatorMobilePhone,
|
|
252
284
|
tt as validatorNumber,
|
|
253
|
-
|
|
285
|
+
dt as validatorPositiveFloat,
|
|
254
286
|
ct as validatorPositiveInt,
|
|
255
287
|
ut as validatorPositiveIntAndZero,
|
|
256
288
|
Y as validatorUpperCase,
|
|
257
289
|
it as validatorUppercaseOrNumbersOrSpecial,
|
|
258
290
|
st as validatorUppercaseOrNumbersOrUnderline,
|
|
259
|
-
|
|
291
|
+
v as warn
|
|
260
292
|
};
|