@lntvow/utils 3.0.3 → 3.0.7

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.js ADDED
@@ -0,0 +1 @@
1
+ function J(...e){return e.reduce((t,r)=>function(...n){return r(t(...n))})}function ee(...e){return e.reduce((t,r)=>function(...n){return t(r(...n))})}function ne(e,t=500){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e.apply(this,n)},t)}}var _=Object.prototype.toString,A=e=>_.call(e),M=null;function se(e){h(e)&&(M=e)}var ae=(e,...t)=>{let r=t.length===0?"":t.length===1?t[0]:t;console.log(`%c ${e} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",r),M&&M(e,r)},ue=(...e)=>console.warn(...e),ce=(...e)=>console.error(...e),pe=e=>A(e)==="[object Map]",me=e=>A(e)==="[object Set]",C=e=>A(e)==="[object Date]",F=e=>A(e)==="[object RegExp]",h=e=>typeof e=="function",f=e=>typeof e=="number",I=e=>typeof e=="string",fe=e=>typeof e=="symbol",c=e=>e!==null&&typeof e=="object",de=e=>c(e)&&h(e.then)&&h(e.catch),d=e=>e==null,ge=e=>e===void 0,xe=e=>e===null,le=e=>e!=null,be=e=>typeof e=="boolean",p=Array.isArray,w=(e,t)=>Object.hasOwn(e,t),ye=(e,t)=>e!==t;function $(e){let t=new WeakMap;function r(n){if(C(n))return new Date(n);if(F(n))return new RegExp(n);if(c(n)){if(t.has(n))return t.get(n);let o={};if(p(n)){o=[],t.set(n,o);for(let i=0;i<n.length;i++)o[i]=r(n[i]);return o}t.set(n,o);for(let i in n)w(n,i)&&(o[i]=r(n[i]));return o}else return n}return r(e)}var R=class extends Error{constructor(t){super(t),this.name="LntvowError"}};function u(e,t){throw new R(`[${e}] ${t}`)}function G(e,t){if(process.env.NODE_ENV!=="production"){let r=I(e)?new R(`[${e}] ${t}`):e;console.warn(r)}}var N=({from:e,replacement:t,version:r,type:n="API"})=>{G(`${n}`,`${e} is about to be deprecated in version ${r}, please use ${t} instead.`)};function l(e,t,r){return(!c(e)||!c(t))&&u("deepMerge","template \u548C source \u5FC5\u987B\u662F\u5BF9\u8C61"),p(e)?z(e,t,r):K(e,t,r)}function K(e,t,r){let n=y(t,r);return Object.keys(e).forEach(i=>{d(t[i])?n[i]=y(e[i],r):n[i]=c(e[i])&&c(t[i])?l(e[i],t[i],r):y(t[i],r)}),n}function z(e,t,r){if(p(t)){let n=y(t,r);return n.push(...y(e,r)),n}else return y(e,r)}function y(e,t){let{deepClone:r=!0}=t||{};return r?$(e):e}function H(e,t){let{decode:r}=l({decode:!0},t||{}),n={};e.startsWith("?")&&(e=e.slice(1)),e.includes("?")&&(e=e.slice(e.indexOf("?")+1));let o=e.split("&").filter(Boolean);for(let i of o){let[b,x]=i.split("=");n[b]=r?decodeURIComponent(x):x}return n}function k(e,t){let{encode:r}=l({encode:!0},t||{}),n=[];for(let o in e){let i=e[o];n.push(`${o}=${r?encodeURIComponent(i):i}`)}return n.join("&")}function W(e,t,r){let n=l({encode:!0},r||{}),o=k(t,n);return e.includes("?")?e.endsWith("?")||e.endsWith("&")?`${e}${o}`:`${e}&${o}`:`${e}?${o}`}var Ie={parse:H,stringify:k,appendQueryString:W};function Pe(e,t=500){let r=null;return function(...n){if(d(r))return r=Date.now(),e.apply(this,n);{let o=Date.now();if(o-r>=t)return r=o,e.apply(this,n)}}}function Ge(e){return/^-?\d{1,3}\.\d{6}$/.test(e)}function Ke(e){return!d(e)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(e)}function ze(e){return!d(e)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(e)}function He(e){return!d(e)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(e)}function We(e){return/^[\dA-Z_]+$/.test(e)}function Le(e){return N({from:"validatorEmail",replacement:"isEmail",version:"2.4.0"}),/^([\w-])+@([\w-])+(\.[\w-])+/.test(e)}function j(e){return p(e)?e:[e]}function gt(e,t){return(!c(e)||!c(t))&&u("deepMerge","template \u548C source \u5FC5\u987B\u662F\u5BF9\u8C61"),p(e)?void 0:Y(e,t)}function Y(e,t){let r={};return Object.keys(e).forEach(n=>{let o=e[n],i=t[n];c(o)&&c(i)?r[n]=Y(o,i):Object.is(o,i)||(r[n]=i)}),r}function Ot(e,t){let r=$(e);return j(t).forEach(o=>{w(r,o)&&delete r[o]}),r}function ht(e,t){let r={};return j(t).forEach(o=>{w(e,o)&&(r[o]=e[o])}),r}function jt(e,t){return(!f(e)||e<=0)&&u("generateRandomArray","num \u5FC5\u987B\u5927\u4E8E0"),h(t)||u("generateRandomArray","cb \u5FC5\u987B\u662F\u51FD\u6570"),Array.from({length:e}).fill(0).map((r,n)=>t(r,n))}function Ct(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}import g,{extend as L}from"dayjs";import q from"dayjs/plugin/customParseFormat";function m(e={}){f(e)&&(e={max:e});let{min:t=0,max:r=Number.MAX_SAFE_INTEGER}=e,n=Math.ceil(t),o=Math.floor(r);return n===o?n:(o<n&&(r>=t&&u("generateRandomInteger",`\u672A\u627E\u5230 ${t} \u548C ${r} \u4E4B\u95F4\u7684\u6574\u6570\u503C`),u("generateRandomInteger",`\u6700\u5927\u503C ${r} \u5E94\u5927\u4E8E\u6700\u5C0F\u503C ${t}`)),Math.floor(Math.random()*(o-n+1)+n))}L(q);function S(e={}){let{start:t="1800-01-01 00:00:00",end:r=g().format("YYYY-MM-DD HH:mm:ss"),format:n="YYYY-MM-DD HH:mm:ss"}=e;(!g(t).isValid()||!g(r).isValid())&&u("generateRandomDate","start end \u53C2\u6570\u5FC5\u987B\u662F\u5408\u6CD5\u7684\u65F6\u95F4\u683C\u5F0F");let o=g(t).year(),i=g(r).year(),b=m({min:o,max:i}),x=m({min:1,max:12}),T=m({min:1,max:31}),U=m(23),v=m(59),Z=m(59),E=g(`${b}-${x}-${T} ${U}:${v}:${Z}`);return E.isBefore(g(t))||E.isAfter(g(r))?S(e):E.format(n)}function P(e,t={}){let{lowerCase:r,upperCase:n,number:o}=l({lowerCase:!0,upperCase:!0,number:!0},t);r||n||o||u("generateRandomString","lowerCase upperCase number \u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u53C2\u6570\u4E3Atrue");let i="";r&&(i+="abcdefghijklmnopqrstuvwxyz"),n&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"),o&&(i+="0123456789");let b="";for(let x=0;x<e;x++){let T=Math.floor(Math.random()*i.length);b+=i.charAt(T)}return b}function O(e){return e[Math.floor(Math.random()*e.length)]}function Bt(){let e=["gmail.com","yahoo.com","outlook.com","example.com","qq.com","163.com"];return`${P(10)}@${O(e)}`}function er(e={}){f(e)&&(e={max:e});let{min:t=0,max:r=1,fractionDigits:n=2}=e;if(t===r)return t;if(t>r)throw new Error(`\u6700\u5927\u503C ${r} \u5E94\u5927\u4E8E\u6700\u5C0F\u503C ${t}`);return Math.random()*(r-t)+t}function D(e,t){(!f(e)||e<=0)&&u("generateRandomStringFromSource","num \u5FC5\u987B\u5927\u4E8E0"),(!p(t)||t.length===0)&&u("generateRandomStringFromSource","source \u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4");let r="";for(let n=0;n<e;n++)r+=O(t);return r}function pr(){let e=m({min:1e5,max:999999}),t=[0,1,2,3,4,5,6,7,8,9];return[e,S({format:"YYYYMMDD"}),D(3,t),D(1,[...t,"X","x"])].join("")}function xr(){return O(["13","14","15","16","17","18","19"])+m(999999999).toString().padEnd(9,"0")}function Cr(e){return/^\d+$/.test(e)}function Fr(e){return/^[\u4E00-\u9FA5]+$/.test(e)}function Ir(e){return/^[A-Za-z]+$/.test(e)}function Nr(e){return/^[A-Z]+$/.test(e)}function kr(e){return/^[\dA-Z]+$/.test(e)}function Yr(e){return/^[\dA-Z\u4E00-\u9FA5]+$/.test(e)}function Pr(e){return/^[a-z]+$/.test(e)}function Ur(e){return/^[\da-z]+$/.test(e)}function vr(e){return/^[\da-z\u4E00-\u9FA5]+$/.test(e)}function Gr(e,t={}){let{integer:r=!0}=t;return r?/^-?(0|[1-9]\d*)(\.\d+)?$/.test(e):/^-?(0|[1-9]\d*)\.\d+$/.test(e)}function Kr(e,t={}){let{integer:r=!0}=t;return r?/^[1-9]\d*\.?\d*|^0\.\d*[1-9]\d*$/.test(e):/^[1-9]\d*\.\d*|^0\.\d*[1-9]\d*$/.test(e)}function zr(e,t={}){let{integer:r=!0}=t;return r?/^-[1-9]\d*\.?\d*|^-0\.\d*[1-9]\d*$/.test(e):/^-[1-9]\d*\.\d*|^-0\.\d*[1-9]\d*$/.test(e)}function Hr(e,t={}){let{integer:r=!0}=t;return r?/^(0|[1-9]\d*)(\.\d+)?$/.test(e):/^(0|[1-9]\d*)\.\d+$/.test(e)}function Wr(e,t={}){let{integer:r=!0}=t;return r?/^(-?0(\.0+)?|-(0|[1-9]\d*)(\.\d+)?)$/.test(e):/^(-?0\.0+|-(0|[1-9]\d*)\.\d+)$/.test(e)}function Vr(e){return/^-?(0|[1-9]\d*)$/.test(e)}function Br(e){return/^[1-9]\d*$/.test(e)}function Xr(e){return/^(0|[1-9]\d*)$/.test(e)}function Qr(e){return/^-([1-9]\d*)$/.test(e)}function Jr(e){return/^(0|-(0|[1-9]\d*))$/.test(e)}import V,{extend as B}from"dayjs";import X from"dayjs/plugin/customParseFormat";function cn(e){return/^1[3-9]\d{9}$/.test(e)}function pn(e){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(e)}function mn(e){return e===""}function Q(e,t="YYYY-MM-DD HH:mm:ss"){return B(X),V(e,t,!0).isValid()}function fn(e){let t=/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[\dX]$/i.test(e);return!t||(t=Q(e.slice(6,14),"YYYYMMDD"),!t),t}function dn(e){return/^(?:http|https):\/\/[\w.]+/.test(e)}export{j as castArray,gt as compareProperties,J as compose,ee as composeRight,ne as debounce,G as debugWarn,$ as deepClone,l as deepMerge,N as deprecated,ce as error,Ot as excludeProperties,ht as extractProperties,jt as generateRandomArray,Ct as generateRandomColor,S as generateRandomDate,Bt as generateRandomEmail,er as generateRandomFloat,pr as generateRandomIdCard,m as generateRandomInteger,xr as generateRandomMobilePhone,P as generateRandomString,D as generateRandomStringFromSource,O as getRandomItem,ye as hasChanged,w as hasOwn,se as initLog,p as isArray,be as isBoolean,Fr as isChinese,C as isDate,Q as isDateString,le as isDef,pn as isEmail,mn as isEmptyString,Ir as isEnglishAphabet,Gr as isFloat,h as isFunction,fn as isIdCard,Vr as isInteger,Pr as isLowerCase,Ur as isLowerCaseAndNumber,vr as isLowerCaseAndNumberAndChinese,pe as isMap,cn as isMobilePhone,zr as isNegativeFloat,Wr as isNegativeFloatOrZero,Qr as isNegativeInteger,Jr as isNegativeIntegerOrZero,xe as isNull,f as isNumber,Cr as isNumberOrNumberString,c as isObject,Kr as isPositiveFloat,Hr as isPositiveFloatOrZero,Br as isPositiveInteger,Xr as isPositiveIntegerOrZero,de as isPromise,F as isRegExp,me as isSet,I as isString,fe as isSymbol,d as isUndef,ge as isUndefined,Nr as isUpperCase,kr as isUpperCaseAndNumber,Yr as isUpperCaseAndNumberAndChinese,dn as isUrl,ae as log,_ as objectToString,Ie as qs,Pe as throttle,u as throwError,A as toTypeString,ze as validatorChineseOrEnglish,Ke as validatorChineseOrEnglishOrNumber,Le as validatorEmail,Ge as validatorLatitudeOrLongitude,He as validatorUppercaseOrNumbersOrSpecial,We as validatorUppercaseOrNumbersOrUnderline,ue as warn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "3.0.3",
3
+ "version": "3.0.7",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -19,20 +19,21 @@
19
19
  "dayjs": "^1.11.11"
20
20
  },
21
21
  "devDependencies": {
22
- "@lntvow/dev": "^1.0.1",
22
+ "@lntvow/dev": "^1.1.2",
23
+ "@lntvow/eslint-config": "^9.3.7",
23
24
  "@vitest/coverage-istanbul": "^1.6.0",
24
25
  "@vitest/ui": "^1.6.0",
25
26
  "deepmerge": "^4.3.1",
27
+ "tsup": "^8.0.2",
26
28
  "typescript": "^5.4.5",
27
29
  "vite": "^5.2.11",
28
- "vite-plugin-dts": "3.6.4",
29
30
  "vitest": "^1.6.0"
30
31
  },
31
32
  "scripts": {
32
33
  "test": "vitest",
33
34
  "test:ui": "vitest --ui",
34
35
  "coverage": "vitest run --coverage",
35
- "build": "vite build",
36
+ "build": "tsup",
36
37
  "commit": "git add . && git-cz && git push",
37
38
  "release": "git add . && bumpp package.json --all --commit --no-tag --push",
38
39
  "rimraf": "rimraf ./node_modules/"
package/dist/index.mjs DELETED
@@ -1,546 +0,0 @@
1
- import p, { extend as st } from "dayjs";
2
- function Tt(...t) {
3
- return t.reduce((e, n) => function(...r) {
4
- return n(e(...r));
5
- });
6
- }
7
- function Ht(...t) {
8
- return t.reduce((e, n) => function(...r) {
9
- return e(n(...r));
10
- });
11
- }
12
- function Ut(t, e = 500) {
13
- let n = null;
14
- return function(...r) {
15
- n && clearTimeout(n), n = setTimeout(() => {
16
- t.apply(this, r);
17
- }, e);
18
- };
19
- }
20
- const bt = Object.prototype.toString, X = (t) => bt.call(t);
21
- let et = null;
22
- function zt(t) {
23
- W(t) && (et = t);
24
- }
25
- const _t = (t, ...e) => {
26
- const n = e.length === 0 ? "" : e.length === 1 ? e[0] : e;
27
- console.log(
28
- `%c ${t} `,
29
- "padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
30
- n
31
- ), et && et(t, n);
32
- }, Vt = (...t) => console.warn(...t), Wt = (...t) => console.error(...t), Xt = (t) => X(t) === "[object Map]", qt = (t) => X(t) === "[object Set]", yt = (t) => X(t) === "[object Date]", At = (t) => X(t) === "[object RegExp]", W = (t) => typeof t == "function", q = (t) => typeof t == "number", xt = (t) => typeof t == "string", Bt = (t) => typeof t == "symbol", $ = (t) => t !== null && typeof t == "object", Gt = (t) => $(t) && W(t.then) && W(t.catch), T = (t) => t == null, Kt = (t) => t === void 0, Qt = (t) => t === null, Jt = (t) => t != null, kt = (t) => typeof t == "boolean", Z = Array.isArray, nt = (t, e) => Object.hasOwn(t, e), te = (t, e) => t !== e;
33
- function at(t) {
34
- const e = /* @__PURE__ */ new WeakMap();
35
- function n(r) {
36
- if (yt(r))
37
- return new Date(r);
38
- if (At(r))
39
- return new RegExp(r);
40
- if ($(r)) {
41
- if (e.has(r))
42
- return e.get(r);
43
- let i = {};
44
- if (Z(r)) {
45
- i = [], e.set(r, i);
46
- for (let o = 0; o < r.length; o++)
47
- i[o] = n(r[o]);
48
- return i;
49
- }
50
- e.set(r, i);
51
- for (const o in r)
52
- nt(r, o) && (i[o] = n(r[o]));
53
- return i;
54
- } else
55
- return r;
56
- }
57
- return n(t);
58
- }
59
- class ct extends Error {
60
- constructor(e) {
61
- super(e), this.name = "LntvowError";
62
- }
63
- }
64
- function M(t, e) {
65
- throw new ct(`[${t}] ${e}`);
66
- }
67
- function Et(t, e) {
68
- if (process.env.NODE_ENV !== "production") {
69
- const n = xt(t) ? new ct(`[${t}] ${e}`) : t;
70
- console.warn(n);
71
- }
72
- }
73
- const St = ({
74
- from: t,
75
- replacement: e,
76
- version: n,
77
- type: r = "API"
78
- }) => {
79
- Et(`${r}`, `${t} is about to be deprecated in version ${n}, please use ${e} instead.`);
80
- };
81
- function H(t, e, n) {
82
- return (!$(t) || !$(e)) && M("deepMerge", "template 和 source 必须是对象"), Z(t) ? Ct(t, e, n) : Ot(t, e, n);
83
- }
84
- function Ot(t, e, n) {
85
- const r = j(e, n);
86
- return Object.keys(t).forEach((o) => {
87
- T(e[o]) ? r[o] = j(t[o], n) : r[o] = $(t[o]) && $(e[o]) ? H(t[o], e[o], n) : j(e[o], n);
88
- }), r;
89
- }
90
- function Ct(t, e, n) {
91
- if (Z(e)) {
92
- const r = j(e, n);
93
- return r.push(...j(t, n)), r;
94
- } else
95
- return j(t, n);
96
- }
97
- function j(t, e) {
98
- const { deepClone: n = !0 } = e || {};
99
- return n ? at(t) : t;
100
- }
101
- function vt(t, e) {
102
- const { decode: n } = H({ decode: !0 }, e || {}), r = {};
103
- t.startsWith("?") && (t = t.slice(1)), t.includes("?") && (t = t.slice(t.indexOf("?") + 1));
104
- const i = t.split("&").filter(Boolean);
105
- for (const o of i) {
106
- const [l, f] = o.split("=");
107
- r[l] = n ? decodeURIComponent(f) : f;
108
- }
109
- return r;
110
- }
111
- function ut(t, e) {
112
- const { encode: n } = H({ encode: !0 }, e || {}), r = [];
113
- for (const i in t) {
114
- const o = t[i];
115
- r.push(`${i}=${n ? encodeURIComponent(o) : o}`);
116
- }
117
- return r.join("&");
118
- }
119
- function Lt(t, e, n) {
120
- const r = H({ encode: !0 }, n || {}), i = ut(e, r);
121
- return t.includes("?") ? t.endsWith("?") || t.endsWith("&") ? `${t}${i}` : `${t}&${i}` : `${t}?${i}`;
122
- }
123
- const ee = {
124
- parse: vt,
125
- stringify: ut,
126
- appendQueryString: Lt
127
- };
128
- function ne(t, e = 500) {
129
- let n = null;
130
- return function(...r) {
131
- if (T(n))
132
- return n = Date.now(), t.apply(this, r);
133
- {
134
- const i = Date.now();
135
- if (i - n >= e)
136
- return n = i, t.apply(this, r);
137
- }
138
- };
139
- }
140
- function re(t) {
141
- return /^-?\d{1,3}\.\d{6}$/.test(t);
142
- }
143
- function oe(t) {
144
- return !T(t) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
145
- }
146
- function ie(t) {
147
- return !T(t) && /^[A-Za-z\u4E00-\u9FA5]+$/.test(t);
148
- }
149
- function se(t) {
150
- return !T(t) && /^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t);
151
- }
152
- function ae(t) {
153
- return /^[\dA-Z_]+$/.test(t);
154
- }
155
- function ce(t) {
156
- return St({ from: "validatorEmail", replacement: "isEmail", version: "2.4.0" }), /^([\w-])+@([\w-])+(\.[\w-])+/.test(t);
157
- }
158
- function ft(t) {
159
- return Z(t) ? t : [t];
160
- }
161
- function ue(t, e) {
162
- return (!$(t) || !$(e)) && M("deepMerge", "template 和 source 必须是对象"), Z(t) ? void 0 : dt(t, e);
163
- }
164
- function dt(t, e) {
165
- const n = {};
166
- return Object.keys(t).forEach((r) => {
167
- const i = t[r], o = e[r];
168
- $(i) && $(o) ? n[r] = dt(i, o) : Object.is(i, o) || (n[r] = o);
169
- }), n;
170
- }
171
- function fe(t, e) {
172
- const n = at(t);
173
- return ft(e).forEach((i) => {
174
- nt(n, i) && delete n[i];
175
- }), n;
176
- }
177
- function de(t, e) {
178
- const n = {};
179
- return ft(e).forEach((i) => {
180
- nt(t, i) && (n[i] = t[i]);
181
- }), n;
182
- }
183
- function le(t, e) {
184
- return (!q(t) || t <= 0) && M("generateRandomArray", "num 必须大于0"), W(e) || M("generateRandomArray", "cb 必须是函数"), Array.from({ length: t }).fill(0).map((n, r) => e(n, r));
185
- }
186
- function me() {
187
- return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
188
- }
189
- var Rt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
190
- function Ft(t) {
191
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
192
- }
193
- var lt = { exports: {} };
194
- (function(t, e) {
195
- (function(n, r) {
196
- t.exports = r();
197
- })(Rt, function() {
198
- var n = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, r = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, i = /\d\d/, o = /\d\d?/, l = /\d*[^-_:/,()\s\d]+/, f = {}, R = function(s) {
199
- return (s = +s) + (s > 68 ? 1900 : 2e3);
200
- }, d = function(s) {
201
- return function(a) {
202
- this[s] = +a;
203
- };
204
- }, U = [/[+-]\d\d:?(\d\d)?|Z/, function(s) {
205
- (this.zone || (this.zone = {})).offset = function(a) {
206
- if (!a || a === "Z")
207
- return 0;
208
- var c = a.match(/([+-]|\d\d)/g), u = 60 * c[1] + (+c[2] || 0);
209
- return u === 0 ? 0 : c[0] === "+" ? -u : u;
210
- }(s);
211
- }], I = function(s) {
212
- var a = f[s];
213
- return a && (a.indexOf ? a : a.s.concat(a.f));
214
- }, S = function(s, a) {
215
- var c, u = f.meridiem;
216
- if (u) {
217
- for (var Y = 1; Y <= 24; Y += 1)
218
- if (s.indexOf(u(Y, 0, a)) > -1) {
219
- c = Y > 12;
220
- break;
221
- }
222
- } else
223
- c = s === (a ? "pm" : "PM");
224
- return c;
225
- }, gt = { A: [l, function(s) {
226
- this.afternoon = S(s, !1);
227
- }], a: [l, function(s) {
228
- this.afternoon = S(s, !0);
229
- }], S: [/\d/, function(s) {
230
- this.milliseconds = 100 * +s;
231
- }], SS: [i, function(s) {
232
- this.milliseconds = 10 * +s;
233
- }], SSS: [/\d{3}/, function(s) {
234
- this.milliseconds = +s;
235
- }], s: [o, d("seconds")], ss: [o, d("seconds")], m: [o, d("minutes")], mm: [o, d("minutes")], H: [o, d("hours")], h: [o, d("hours")], HH: [o, d("hours")], hh: [o, d("hours")], D: [o, d("day")], DD: [i, d("day")], Do: [l, function(s) {
236
- var a = f.ordinal, c = s.match(/\d+/);
237
- if (this.day = c[0], a)
238
- for (var u = 1; u <= 31; u += 1)
239
- a(u).replace(/\[|\]/g, "") === s && (this.day = u);
240
- }], M: [o, d("month")], MM: [i, d("month")], MMM: [l, function(s) {
241
- var a = I("months"), c = (I("monthsShort") || a.map(function(u) {
242
- return u.slice(0, 3);
243
- })).indexOf(s) + 1;
244
- if (c < 1)
245
- throw new Error();
246
- this.month = c % 12 || c;
247
- }], MMMM: [l, function(s) {
248
- var a = I("months").indexOf(s) + 1;
249
- if (a < 1)
250
- throw new Error();
251
- this.month = a % 12 || a;
252
- }], Y: [/[+-]?\d+/, d("year")], YY: [i, function(s) {
253
- this.year = R(s);
254
- }], YYYY: [/\d{4}/, d("year")], Z: U, ZZ: U };
255
- function pt(s) {
256
- var a, c;
257
- a = s, c = f && f.formats;
258
- for (var u = (s = a.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function(C, y, g) {
259
- var m = g && g.toUpperCase();
260
- return y || c[g] || n[g] || c[m].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(A, x, v) {
261
- return x || v.slice(1);
262
- });
263
- })).match(r), Y = u.length, w = 0; w < Y; w += 1) {
264
- var P = u[w], O = gt[P], D = O && O[0], b = O && O[1];
265
- u[w] = b ? { regex: D, parser: b } : P.replace(/^\[|\]$/g, "");
266
- }
267
- return function(C) {
268
- for (var y = {}, g = 0, m = 0; g < Y; g += 1) {
269
- var A = u[g];
270
- if (typeof A == "string")
271
- m += A.length;
272
- else {
273
- var x = A.regex, v = A.parser, z = C.slice(m), F = x.exec(z)[0];
274
- v.call(y, F), C = C.replace(F, "");
275
- }
276
- }
277
- return function(L) {
278
- var h = L.afternoon;
279
- if (h !== void 0) {
280
- var N = L.hours;
281
- h ? N < 12 && (L.hours += 12) : N === 12 && (L.hours = 0), delete L.afternoon;
282
- }
283
- }(y), y;
284
- };
285
- }
286
- return function(s, a, c) {
287
- c.p.customParseFormat = !0, s && s.parseTwoDigitYear && (R = s.parseTwoDigitYear);
288
- var u = a.prototype, Y = u.parse;
289
- u.parse = function(w) {
290
- var P = w.date, O = w.utc, D = w.args;
291
- this.$u = O;
292
- var b = D[1];
293
- if (typeof b == "string") {
294
- var C = D[2] === !0, y = D[3] === !0, g = C || y, m = D[2];
295
- y && (m = D[2]), f = this.$locale(), !C && m && (f = c.Ls[m]), this.$d = function(z, F, L) {
296
- try {
297
- if (["x", "X"].indexOf(F) > -1)
298
- return new Date((F === "X" ? 1e3 : 1) * z);
299
- var h = pt(F)(z), N = h.year, _ = h.month, $t = h.day, Mt = h.hours, Yt = h.minutes, wt = h.seconds, Dt = h.milliseconds, ot = h.zone, B = /* @__PURE__ */ new Date(), G = $t || (N || _ ? 1 : B.getDate()), K = N || B.getFullYear(), V = 0;
300
- N && !_ || (V = _ > 0 ? _ - 1 : B.getMonth());
301
- var Q = Mt || 0, J = Yt || 0, k = wt || 0, tt = Dt || 0;
302
- return ot ? new Date(Date.UTC(K, V, G, Q, J, k, tt + 60 * ot.offset * 1e3)) : L ? new Date(Date.UTC(K, V, G, Q, J, k, tt)) : new Date(K, V, G, Q, J, k, tt);
303
- } catch {
304
- return /* @__PURE__ */ new Date("");
305
- }
306
- }(P, b, O), this.init(), m && m !== !0 && (this.$L = this.locale(m).$L), g && P != this.format(b) && (this.$d = /* @__PURE__ */ new Date("")), f = {};
307
- } else if (b instanceof Array)
308
- for (var A = b.length, x = 1; x <= A; x += 1) {
309
- D[1] = b[x - 1];
310
- var v = c.apply(this, D);
311
- if (v.isValid()) {
312
- this.$d = v.$d, this.$L = v.$L, this.init();
313
- break;
314
- }
315
- x === A && (this.$d = /* @__PURE__ */ new Date(""));
316
- }
317
- else
318
- Y.call(this, w);
319
- };
320
- };
321
- });
322
- })(lt);
323
- var Nt = lt.exports;
324
- const mt = /* @__PURE__ */ Ft(Nt);
325
- function E(t = {}) {
326
- q(t) && (t = { max: t });
327
- const { min: e = 0, max: n = Number.MAX_SAFE_INTEGER } = t, r = Math.ceil(e), i = Math.floor(n);
328
- return r === i ? r : (i < r && (n >= e && M("generateRandomInteger", `未找到 ${e} 和 ${n} 之间的整数值`), M("generateRandomInteger", `最大值 ${n} 应大于最小值 ${e}`)), Math.floor(Math.random() * (i - r + 1) + r));
329
- }
330
- st(mt);
331
- function ht(t = {}) {
332
- const {
333
- start: e = "1800-01-01 00:00:00",
334
- end: n = p().format("YYYY-MM-DD HH:mm:ss"),
335
- format: r = "YYYY-MM-DD HH:mm:ss"
336
- } = t;
337
- (!p(e).isValid() || !p(n).isValid()) && M("generateRandomDate", "start end 参数必须是合法的时间格式");
338
- const i = p(e).year(), o = p(n).year(), l = E({ min: i, max: o }), f = E({ min: 1, max: 12 }), R = E({ min: 1, max: 31 }), d = E(23), U = E(59), I = E(59), S = p(`${l}-${f}-${R} ${d}:${U}:${I}`);
339
- return S.isBefore(p(e)) || S.isAfter(p(n)) ? (console.log("不合法时间", p(S).format("YYYY-MM-DD HH:mm:ss")), ht(t)) : S.format(r);
340
- }
341
- function jt(t, e = {}) {
342
- const { lowerCase: n, upperCase: r, number: i } = H({ lowerCase: !0, upperCase: !0, number: !0 }, e);
343
- n || r || i || M("generateRandomString", "lowerCase upperCase number 至少需要一个参数为true");
344
- let o = "";
345
- n && (o += "abcdefghijklmnopqrstuvwxyz"), r && (o += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), i && (o += "0123456789");
346
- let l = "";
347
- for (let f = 0; f < t; f++) {
348
- const R = Math.floor(Math.random() * o.length);
349
- l += o.charAt(R);
350
- }
351
- return l;
352
- }
353
- function rt(t) {
354
- return t[Math.floor(Math.random() * t.length)];
355
- }
356
- function he() {
357
- const t = ["gmail.com", "yahoo.com", "outlook.com", "example.com", "qq.com", "163.com"];
358
- return `${jt(10)}@${rt(t)}`;
359
- }
360
- function ge(t = {}) {
361
- q(t) && (t = { max: t });
362
- const { min: e = 0, max: n = 1, fractionDigits: r = 2 } = t;
363
- if (e === n)
364
- return e;
365
- if (e > n)
366
- throw new Error(`最大值 ${n} 应大于最小值 ${e}`);
367
- return Math.random() * (n - e) + e;
368
- }
369
- function it(t, e) {
370
- (!q(t) || t <= 0) && M("generateRandomStringFromSource", "num 必须大于0"), (!Z(e) || e.length === 0) && M("generateRandomStringFromSource", "source 不能为空数组");
371
- let n = "";
372
- for (let r = 0; r < t; r++)
373
- n += rt(e);
374
- return n;
375
- }
376
- function pe() {
377
- const t = E({ min: 1e5, max: 999999 }), e = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
378
- return [
379
- t,
380
- ht({ format: "YYYYMMDD" }),
381
- it(3, e),
382
- it(1, [...e, "X", "x"])
383
- ].join("");
384
- }
385
- function $e() {
386
- return rt(["13", "14", "15", "16", "17", "18", "19"]) + E(999999999).toString().padEnd(9, "0");
387
- }
388
- function Me(t) {
389
- return /^\d+$/.test(t);
390
- }
391
- function Ye(t) {
392
- return /^[\u4E00-\u9FA5]+$/.test(t);
393
- }
394
- function we(t) {
395
- return /^[A-Za-z]+$/.test(t);
396
- }
397
- function De(t) {
398
- return /^[A-Z]+$/.test(t);
399
- }
400
- function be(t) {
401
- return /^[\dA-Z]+$/.test(t);
402
- }
403
- function ye(t) {
404
- return /^[\dA-Z\u4E00-\u9FA5]+$/.test(t);
405
- }
406
- function Ae(t) {
407
- return /^[a-z]+$/.test(t);
408
- }
409
- function xe(t) {
410
- return /^[\da-z]+$/.test(t);
411
- }
412
- function Ee(t) {
413
- return /^[\da-z\u4E00-\u9FA5]+$/.test(t);
414
- }
415
- function Se(t, e = {}) {
416
- const { integer: n = !0 } = e;
417
- return n ? /^-?(0|[1-9]\d*)(\.\d+)?$/.test(t) : /^-?(0|[1-9]\d*)\.\d+$/.test(t);
418
- }
419
- function Oe(t, e = {}) {
420
- const { integer: n = !0 } = e;
421
- return n ? /^[1-9]\d*\.?\d*|^0\.\d*[1-9]\d*$/.test(t) : /^[1-9]\d*\.\d*|^0\.\d*[1-9]\d*$/.test(t);
422
- }
423
- function Ce(t, e = {}) {
424
- const { integer: n = !0 } = e;
425
- return n ? /^-[1-9]\d*\.?\d*|^-0\.\d*[1-9]\d*$/.test(t) : /^-[1-9]\d*\.\d*|^-0\.\d*[1-9]\d*$/.test(t);
426
- }
427
- function ve(t, e = {}) {
428
- const { integer: n = !0 } = e;
429
- return n ? /^(0|[1-9]\d*)(\.\d+)?$/.test(t) : /^(0|[1-9]\d*)\.\d+$/.test(t);
430
- }
431
- function Le(t, e = {}) {
432
- const { integer: n = !0 } = e;
433
- return n ? /^(-?0(\.0+)?|-(0|[1-9]\d*)(\.\d+)?)$/.test(t) : /^(-?0\.0+|-(0|[1-9]\d*)\.\d+)$/.test(t);
434
- }
435
- function Re(t) {
436
- return /^-?(0|[1-9]\d*)$/.test(t);
437
- }
438
- function Fe(t) {
439
- return /^[1-9]\d*$/.test(t);
440
- }
441
- function Ne(t) {
442
- return /^(0|[1-9]\d*)$/.test(t);
443
- }
444
- function je(t) {
445
- return /^-([1-9]\d*)$/.test(t);
446
- }
447
- function Ze(t) {
448
- return /^(0|-(0|[1-9]\d*))$/.test(t);
449
- }
450
- function Ie(t) {
451
- return /^1[3-9]\d{9}$/.test(t);
452
- }
453
- function Pe(t) {
454
- return /^([\w-])+@([\w-])+(\.[\w-])+/.test(t);
455
- }
456
- function Te(t) {
457
- return t === "";
458
- }
459
- function Zt(t, e = "YYYY-MM-DD HH:mm:ss") {
460
- return st(mt), p(t, e, !0).isValid();
461
- }
462
- function He(t) {
463
- let e = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(t);
464
- return !e || (e = Zt(t.slice(6, 14), "YYYYMMDD"), !e), e;
465
- }
466
- export {
467
- ft as castArray,
468
- ue as compareProperties,
469
- Tt as compose,
470
- Ht as composeRight,
471
- Ut as debounce,
472
- Et as debugWarn,
473
- at as deepClone,
474
- H as deepMerge,
475
- St as deprecated,
476
- Wt as error,
477
- fe as excludeProperties,
478
- de as extractProperties,
479
- le as generateRandomArray,
480
- me as generateRandomColor,
481
- ht as generateRandomDate,
482
- he as generateRandomEmail,
483
- ge as generateRandomFloat,
484
- pe as generateRandomIdCard,
485
- E as generateRandomInteger,
486
- $e as generateRandomMobilePhone,
487
- jt as generateRandomString,
488
- it as generateRandomStringFromSource,
489
- rt as getRandomItem,
490
- te as hasChanged,
491
- nt as hasOwn,
492
- zt as initLog,
493
- Z as isArray,
494
- kt as isBoolean,
495
- Ye as isChinese,
496
- yt as isDate,
497
- Zt as isDateString,
498
- Jt as isDef,
499
- Pe as isEmail,
500
- Te as isEmptyString,
501
- we as isEnglishAphabet,
502
- Se as isFloat,
503
- W as isFunction,
504
- He as isIdCard,
505
- Re as isInteger,
506
- Ae as isLowerCase,
507
- xe as isLowerCaseAndNumber,
508
- Ee as isLowerCaseAndNumberAndChinese,
509
- Xt as isMap,
510
- Ie as isMobilePhone,
511
- Ce as isNegativeFloat,
512
- Le as isNegativeFloatOrZero,
513
- je as isNegativeInteger,
514
- Ze as isNegativeIntegerOrZero,
515
- Qt as isNull,
516
- q as isNumber,
517
- Me as isNumberOrNumberString,
518
- $ as isObject,
519
- Oe as isPositiveFloat,
520
- ve as isPositiveFloatOrZero,
521
- Fe as isPositiveInteger,
522
- Ne as isPositiveIntegerOrZero,
523
- Gt as isPromise,
524
- At as isRegExp,
525
- qt as isSet,
526
- xt as isString,
527
- Bt as isSymbol,
528
- T as isUndef,
529
- Kt as isUndefined,
530
- De as isUpperCase,
531
- be as isUpperCaseAndNumber,
532
- ye as isUpperCaseAndNumberAndChinese,
533
- _t as log,
534
- bt as objectToString,
535
- ee as qs,
536
- ne as throttle,
537
- M as throwError,
538
- X as toTypeString,
539
- ie as validatorChineseOrEnglish,
540
- oe as validatorChineseOrEnglishOrNumber,
541
- ce as validatorEmail,
542
- re as validatorLatitudeOrLongitude,
543
- se as validatorUppercaseOrNumbersOrSpecial,
544
- ae as validatorUppercaseOrNumbersOrUnderline,
545
- Vt as warn
546
- };