@lntvow/utils 2.1.10 → 2.1.16

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