@lntvow/utils 2.2.3 → 2.2.5

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"});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 F(t,e=500){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{t.apply(this,r)},e)}}const $=Object.prototype.toString,d=t=>$.call(t);let m=null;function M(t){p(t)&&(m=t)}const R=(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),m&&m(t,n)},A=(...t)=>console.warn(...t),Z=(...t)=>console.error(...t),x=t=>d(t)==="[object Map]",U=t=>d(t)==="[object Set]",v=t=>d(t)==="[object Date]",w=t=>d(t)==="[object RegExp]",p=t=>typeof t=="function",j=t=>typeof t=="number",y=t=>typeof t=="string",L=t=>typeof t=="symbol",u=t=>t!==null&&typeof t=="object",D=t=>u(t)&&p(t.then)&&p(t.catch),s=t=>t==null,T=t=>t===void 0,W=t=>t===null,q=t=>t!=null,z=t=>typeof t=="boolean",l=Array.isArray,h=(t,e)=>Object.hasOwn(t,e),B=(t,e)=>t!==e;function b(t){const e=new WeakMap;function n(r){if(v(r))return new Date(r);if(w(r))return new RegExp(r);if(u(r)){if(e.has(r))return e.get(r);let o={};if(l(r)){o=[],e.set(r,o);for(let i=0;i<r.length;i++)o[i]=n(r[i]);return o}e.set(r,o);for(const i in r)h(r,i)&&(o[i]=n(r[i]));return o}else return r}return n(t)}function f(t,e,n){return l(t)?K(t,e,n):_(t,e,n)}function _(t,e,n){const r=c(e,n);return Object.keys(t).forEach(i=>{s(e[i])?r[i]=c(t[i],n):r[i]=u(t[i])&&u(e[i])?f(t[i],e[i],n):c(e[i],n)}),r}function K(t,e,n){if(l(e)){const r=c(e,n);return r.push(...c(t,n)),r}else return c(t,n)}function c(t,e){const{clone:n=!0}=e||{};return n?b(t):t}class E extends Error{constructor(e){super(e),this.name="LntvowError"}}function P(t,e){throw new E(`[${t}] ${e}`)}function Q(t,e){if(process.env.NODE_ENV!=="production"){const n=y(t)?new E(`[${t}] ${e}`):t;console.warn(n)}}function V(t,e){const{decode:n}=f({decode:!0},e||{}),r={};t.startsWith("?")&&(t=t.slice(1)),t.includes("?")&&(t=t.slice(t.indexOf("?")+1));const o=t.split("&").filter(Boolean);for(const i of o){const[g,a]=i.split("=");r[g]=n?decodeURIComponent(a):a}return r}function S(t,e){const{encode:n}=f({encode:!0},e||{}),r=[];for(const o in t){const i=t[o];r.push(`${o}=${n?encodeURIComponent(i):i}`)}return r.join("&")}function G(t,e,n){const r=f({encode:!0},n||{}),o=S(e,r);return t.includes("?")?t.endsWith("?")||t.endsWith("&")?`${t}${o}`:`${t}&${o}`:`${t}?${o}`}const H={parse:V,stringify:S,appendQueryString:G};function J(t,e=500){let n=null;return function(...r){if(s(n))return n=Date.now(),t.apply(this,r);{const o=Date.now();if(o-n>=e)return n=o,t.apply(this,r)}}}function X(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 Y(t){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(t)}function k(t){return/^[A-Z]+$/.test(t)}function tt(t){return!s(t)&&/^[a-z]+$/.test(t)}function et(t){return/^\d+$/.test(t)}function nt(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function rt(t){return t===""}function ot(t){return!s(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function it(t){return!s(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function st(t){return!s(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function ct(t){return/^[\dA-Z_]+$/.test(t)}function at(t){return/^[1-9]\d*$/.test(t)}function ut(t){return/^\d+$/.test(t)}function dt(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function O(t){return l(t)?t:[t]}function lt(t,e){const n=b(t);return O(e).forEach(o=>{h(n,o)&&delete n[o]}),n}function ft(t,e){const n={};return O(e).forEach(o=>{h(t,o)&&(n[o]=t[o])}),n}function gt(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function pt(t=0,e=1e6){return Math.random()*(e-t)+t}function ht(t=0,e=1e6){return Math.floor(Math.random()*(e-t+1))+Math.floor(t)}function mt(t,e={}){const{lowerCase:n=!0,upperCase:r=!0,number:o=!0}=e;n||r||o||P("getRandomString","lowerCase upperCase number 至少需要一个参数为true");let i="";n&&(i+="abcdefghijklmnopqrstuvwxyz"),r&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"),o&&(i+="0123456789");let g="";for(let a=0;a<t;a++){const C=Math.floor(Math.random()*i.length);g+=i.charAt(C)}return g}function bt(t){return/^-?(0|[1-9]\d*)$/.test(t)}function Ot(t){return/^[1-9]\d*$/.test(t)}function $t(t){return/^(0|[1-9]\d*)$/.test(t)}function vt(t){return/^-([1-9]\d*)$/.test(t)}function wt(t){return/^(0|-(0|[1-9]\d*))$/.test(t)}function yt(t,e){return/^-?\d+(\.\d+)?$/.test(t)}function Et(t){return/^(0\.\d+|[1-9]\d*(\.\d+)?)$/.test(t)}function Pt(t){return/^-\d+(\.\d+)?$/.test(t)}function St(t){return/^\d+(\.\d+)?$/.test(t)}function Ct(t){return/^(-\d+(\.\d+)?$)|(0(\.0+)?)$/.test(t)}exports.castArray=O;exports.compose=N;exports.composeRight=I;exports.debounce=F;exports.debugWarn=Q;exports.deepClone=b;exports.deepMerge=f;exports.error=Z;exports.excludeProperties=lt;exports.extractProperties=ft;exports.getRandomColor=gt;exports.getRandomFloat=pt;exports.getRandomInteger=ht;exports.getRandomString=mt;exports.hasChanged=B;exports.hasOwn=h;exports.initLog=M;exports.isArray=l;exports.isBoolean=z;exports.isDate=v;exports.isDef=q;exports.isEmptyString=rt;exports.isFloat=yt;exports.isFunction=p;exports.isInteger=bt;exports.isMap=x;exports.isNegativeFloat=Pt;exports.isNegativeFloatOrZero=Ct;exports.isNegativeInteger=vt;exports.isNegativeIntegerOrZero=wt;exports.isNull=W;exports.isNumber=j;exports.isObject=u;exports.isPositiveFloat=Et;exports.isPositiveFloatOrZero=St;exports.isPositiveInteger=Ot;exports.isPositiveIntegerOrZero=$t;exports.isPromise=D;exports.isRegExp=w;exports.isSet=U;exports.isString=y;exports.isSymbol=L;exports.isUndef=s;exports.isUndefined=T;exports.log=R;exports.objectToString=$;exports.qs=H;exports.throttle=J;exports.throwError=P;exports.toTypeString=d;exports.validatorChineseOrEnglish=it;exports.validatorChineseOrEnglishOrNumber=ot;exports.validatorEmail=Y;exports.validatorLatitudeOrLongitude=nt;exports.validatorLowerCase=tt;exports.validatorMobilePhone=X;exports.validatorNumber=et;exports.validatorPositiveFloat=dt;exports.validatorPositiveInt=at;exports.validatorPositiveIntAndZero=ut;exports.validatorUpperCase=k;exports.validatorUppercaseOrNumbersOrSpecial=st;exports.validatorUppercaseOrNumbersOrUnderline=ct;exports.warn=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function P(...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 F(t,e=500){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{t.apply(this,r)},e)}}const O=Object.prototype.toString,l=t=>O.call(t);let m=null;function A(t){p(t)&&(m=t)}const M=(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),m&&m(t,n)},R=(...t)=>console.warn(...t),Z=(...t)=>console.error(...t),x=t=>l(t)==="[object Map]",U=t=>l(t)==="[object Set]",w=t=>l(t)==="[object Date]",v=t=>l(t)==="[object RegExp]",p=t=>typeof t=="function",j=t=>typeof t=="number",E=t=>typeof t=="string",L=t=>typeof t=="symbol",a=t=>t!==null&&typeof t=="object",D=t=>a(t)&&p(t.then)&&p(t.catch),c=t=>t==null,T=t=>t===void 0,W=t=>t===null,_=t=>t!=null,q=t=>typeof t=="boolean",f=Array.isArray,h=(t,e)=>Object.hasOwn(t,e),z=(t,e)=>t!==e;function $(t){const e=new WeakMap;function n(r){if(w(r))return new Date(r);if(v(r))return new RegExp(r);if(a(r)){if(e.has(r))return e.get(r);let o={};if(f(r)){o=[],e.set(r,o);for(let i=0;i<r.length;i++)o[i]=n(r[i]);return o}e.set(r,o);for(const i in r)h(r,i)&&(o[i]=n(r[i]));return o}else return r}return n(t)}function s(t,e,n){return f(t)?K(t,e,n):B(t,e,n)}function B(t,e,n){const r=u(e,n);return Object.keys(t).forEach(i=>{c(e[i])?r[i]=u(t[i],n):r[i]=a(t[i])&&a(e[i])?s(t[i],e[i],n):u(e[i],n)}),r}function K(t,e,n){if(f(e)){const r=u(e,n);return r.push(...u(t,n)),r}else return u(t,n)}function u(t,e){const{clone:n=!0}=e||{};return n?$(t):t}class y extends Error{constructor(e){super(e),this.name="LntvowError"}}function C(t,e){throw new y(`[${t}] ${e}`)}function G(t,e){if(process.env.NODE_ENV!=="production"){const n=E(t)?new y(`[${t}] ${e}`):t;console.warn(n)}}function Q(t,e){const{decode:n}=s({decode:!0},e||{}),r={};t.startsWith("?")&&(t=t.slice(1)),t.includes("?")&&(t=t.slice(t.indexOf("?")+1));const o=t.split("&").filter(Boolean);for(const i of o){const[g,d]=i.split("=");r[g]=n?decodeURIComponent(d):d}return r}function N(t,e){const{encode:n}=s({encode:!0},e||{}),r=[];for(const o in t){const i=t[o];r.push(`${o}=${n?encodeURIComponent(i):i}`)}return r.join("&")}function V(t,e,n){const r=s({encode:!0},n||{}),o=N(e,r);return t.includes("?")?t.endsWith("?")||t.endsWith("&")?`${t}${o}`:`${t}&${o}`:`${t}?${o}`}const X={parse:Q,stringify:N,appendQueryString:V};function H(t,e=500){let n=null;return function(...r){if(c(n))return n=Date.now(),t.apply(this,r);{const o=Date.now();if(o-n>=e)return n=o,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 Y(t){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(t)}function k(t){return/^[A-Z]+$/.test(t)}function tt(t){return!c(t)&&/^[a-z]+$/.test(t)}function et(t){return/^\d+$/.test(t)}function nt(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function rt(t){return t===""}function ot(t){return!c(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function it(t){return!c(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function st(t){return!c(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function ct(t){return/^[\dA-Z_]+$/.test(t)}function ut(t){return/^[1-9]\d*$/.test(t)}function dt(t){return/^\d+$/.test(t)}function at(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function b(t){return f(t)?t:[t]}function lt(t,e){const n=$(t);return b(e).forEach(o=>{h(n,o)&&delete n[o]}),n}function ft(t,e){const n={};return b(e).forEach(o=>{h(t,o)&&(n[o]=t[o])}),n}function gt(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function pt(t=0,e=1e9){return Math.random()*(e-t)+t}function ht(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t+1))+Math.floor(t)}function mt(t,e={}){const{lowerCase:n,upperCase:r,number:o}=s({lowerCase:!0,upperCase:!0,number:!0},e);n||r||o||C("getRandomString","lowerCase upperCase number 至少需要一个参数为true");let i="";n&&(i+="abcdefghijklmnopqrstuvwxyz"),r&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"),o&&(i+="0123456789");let g="";for(let d=0;d<t;d++){const S=Math.floor(Math.random()*i.length);g+=i.charAt(S)}return g}function $t(t){return/^-?(0|[1-9]\d*)$/.test(t)}function bt(t){return/^[1-9]\d*$/.test(t)}function Ot(t){return/^(0|[1-9]\d*)$/.test(t)}function wt(t){return/^-([1-9]\d*)$/.test(t)}function vt(t){return/^(0|-(0|[1-9]\d*))$/.test(t)}function Et(t,e={}){const{integer:n}=s({integer:!0},e);return n?/^-?(0|[1-9]\d*)(\.\d+)?$/.test(t):/^-?(0|[1-9]\d*)\.\d+$/.test(t)}function yt(t,e={}){const{integer:n}=s({integer:!0},e);return n?/^[1-9]\d*\.?\d*|^0\.\d*[1-9]\d*$/.test(t):/^[1-9]\d*\.\d*|^0\.\d*[1-9]\d*$/.test(t)}function Ct(t,e={}){const{integer:n}=s({integer:!0},e);return n?/^-[1-9]\d*\.?\d*|^-0\.\d*[1-9]\d*$/.test(t):/^-[1-9]\d*\.\d*|^-0\.\d*[1-9]\d*$/.test(t)}function Nt(t,e={}){const{integer:n}=s({integer:!0},e);return n?/^(0|[1-9]\d*)(\.\d+)?$/.test(t):/^(0|[1-9]\d*)\.\d+$/.test(t)}function St(t,e={}){const{integer:n}=s({integer:!0},e);return n?/^(-?0(\.0+)?|-(0|[1-9]\d*)(\.\d+)?)$/.test(t):/^(-?0\.0+|-(0|[1-9]\d*)\.\d+)$/.test(t)}exports.castArray=b;exports.compose=P;exports.composeRight=I;exports.debounce=F;exports.debugWarn=G;exports.deepClone=$;exports.deepMerge=s;exports.error=Z;exports.excludeProperties=lt;exports.extractProperties=ft;exports.getRandomColor=gt;exports.getRandomFloat=pt;exports.getRandomInteger=ht;exports.getRandomString=mt;exports.hasChanged=z;exports.hasOwn=h;exports.initLog=A;exports.isArray=f;exports.isBoolean=q;exports.isDate=w;exports.isDef=_;exports.isEmptyString=rt;exports.isFloat=Et;exports.isFunction=p;exports.isInteger=$t;exports.isMap=x;exports.isNegativeFloat=Ct;exports.isNegativeFloatOrZero=St;exports.isNegativeInteger=wt;exports.isNegativeIntegerOrZero=vt;exports.isNull=W;exports.isNumber=j;exports.isObject=a;exports.isPositiveFloat=yt;exports.isPositiveFloatOrZero=Nt;exports.isPositiveInteger=bt;exports.isPositiveIntegerOrZero=Ot;exports.isPromise=D;exports.isRegExp=v;exports.isSet=U;exports.isString=E;exports.isSymbol=L;exports.isUndef=c;exports.isUndefined=T;exports.log=M;exports.objectToString=O;exports.qs=X;exports.throttle=H;exports.throwError=C;exports.toTypeString=l;exports.validatorChineseOrEnglish=it;exports.validatorChineseOrEnglishOrNumber=ot;exports.validatorEmail=Y;exports.validatorLatitudeOrLongitude=nt;exports.validatorLowerCase=tt;exports.validatorMobilePhone=J;exports.validatorNumber=et;exports.validatorPositiveFloat=at;exports.validatorPositiveInt=ut;exports.validatorPositiveIntAndZero=dt;exports.validatorUpperCase=k;exports.validatorUppercaseOrNumbersOrSpecial=st;exports.validatorUppercaseOrNumbersOrUnderline=ct;exports.warn=R;
package/dist/index.d.ts CHANGED
@@ -85,7 +85,7 @@ export declare function extractProperties<T extends AnyObj, K extends keyof T>(o
85
85
  export declare interface FloatOptions {
86
86
  /**
87
87
  * @description 是否包括整数
88
- * @default false
88
+ * @default true
89
89
  */
90
90
  integer?: boolean;
91
91
  }
@@ -101,7 +101,7 @@ export declare function getRandomColor(): string;
101
101
  /**
102
102
  * @description 获取范围内的随机浮点数
103
103
  * @param min 最小值 默认值为 0
104
- * @param max 最大值 默认值为 1000000
104
+ * @param max 最大值 默认值为 1_000_000_000
105
105
  * @return 随机整数
106
106
  *
107
107
  * @example getRandomFloat() => 390083.99373681104
@@ -111,7 +111,7 @@ export declare function getRandomFloat(min?: number, max?: number): number;
111
111
  /**
112
112
  * @description 获取范围内的随机整数
113
113
  * @param min 最小值 默认值为 0
114
- * @param max 最大值 默认值为 1000000
114
+ * @param max 最大值 默认值为 Number.MAX_SAFE_INTEGER
115
115
  * @return 随机整数
116
116
  *
117
117
  * @example getRandomInteger() => 217342
@@ -181,12 +181,12 @@ export declare const isMap: (val: unknown) => val is Map<any, any>;
181
181
  /**
182
182
  * @description 校验是否为小于零的浮点数
183
183
  */
184
- export declare function isNegativeFloat(val: string): boolean;
184
+ export declare function isNegativeFloat(val: string, floatOptions?: FloatOptions): boolean;
185
185
 
186
186
  /**
187
187
  * @description 校验是否为小于等于零的浮点数
188
188
  */
189
- export declare function isNegativeFloatOrZero(val: string): boolean;
189
+ export declare function isNegativeFloatOrZero(val: string, floatOptions?: FloatOptions): boolean;
190
190
 
191
191
  /**
192
192
  * @description 校验是否为负整数
@@ -207,12 +207,12 @@ export declare const isObject: (val: unknown) => val is Record<any, any>;
207
207
  /**
208
208
  * @description 校验是否为大于零的浮点数
209
209
  */
210
- export declare function isPositiveFloat(val: string): boolean;
210
+ export declare function isPositiveFloat(val: string, floatOptions?: FloatOptions): boolean;
211
211
 
212
212
  /**
213
213
  * @description 校验是否为大于等于零的浮点数
214
214
  */
215
- export declare function isPositiveFloatOrZero(val: string): boolean;
215
+ export declare function isPositiveFloatOrZero(val: string, floatOptions?: FloatOptions): boolean;
216
216
 
217
217
  /**
218
218
  * @description 校验否为正整数
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- function R(...t) {
1
+ function F(...t) {
2
2
  return t.reduce((n, e) => function(...r) {
3
3
  return e(n(...r));
4
4
  });
5
5
  }
6
- function j(...t) {
6
+ function P(...t) {
7
7
  return t.reduce((n, e) => function(...r) {
8
8
  return n(e(...r));
9
9
  });
10
10
  }
11
- function F(t, n = 500) {
11
+ function j(t, n = 500) {
12
12
  let e = null;
13
13
  return function(...r) {
14
14
  e && clearTimeout(e), e = setTimeout(() => {
@@ -16,19 +16,19 @@ function F(t, n = 500) {
16
16
  }, n);
17
17
  };
18
18
  }
19
- const y = Object.prototype.toString, a = (t) => y.call(t);
20
- let g = null;
19
+ const y = Object.prototype.toString, l = (t) => y.call(t);
20
+ let p = null;
21
21
  function Z(t) {
22
- h(t) && (g = t);
22
+ h(t) && (p = t);
23
23
  }
24
- const v = (t, ...n) => {
24
+ const U = (t, ...n) => {
25
25
  const e = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
26
26
  console.log(
27
27
  `%c ${t} `,
28
28
  "padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
29
29
  e
30
- ), g && g(t, e);
31
- }, U = (...t) => console.warn(...t), D = (...t) => console.error(...t), L = (t) => a(t) === "[object Map]", W = (t) => a(t) === "[object Set]", C = (t) => a(t) === "[object Date]", A = (t) => a(t) === "[object RegExp]", h = (t) => typeof t == "function", T = (t) => typeof t == "number", M = (t) => typeof t == "string", z = (t) => typeof t == "symbol", d = (t) => t !== null && typeof t == "object", _ = (t) => d(t) && h(t.then) && h(t.catch), c = (t) => t == null, q = (t) => t === void 0, B = (t) => t === null, K = (t) => t != null, Q = (t) => typeof t == "boolean", l = Array.isArray, $ = (t, n) => Object.hasOwn(t, n), V = (t, n) => t !== n;
30
+ ), p && p(t, e);
31
+ }, D = (...t) => console.warn(...t), L = (...t) => console.error(...t), T = (t) => l(t) === "[object Map]", W = (t) => l(t) === "[object Set]", C = (t) => l(t) === "[object Date]", A = (t) => l(t) === "[object RegExp]", h = (t) => typeof t == "function", _ = (t) => typeof t == "number", M = (t) => typeof t == "string", v = (t) => typeof t == "symbol", a = (t) => t !== null && typeof t == "object", z = (t) => a(t) && h(t.then) && h(t.catch), u = (t) => t == null, q = (t) => t === void 0, B = (t) => t === null, K = (t) => t != null, G = (t) => typeof t == "boolean", g = Array.isArray, $ = (t, n) => Object.hasOwn(t, n), Q = (t, n) => t !== n;
32
32
  function m(t) {
33
33
  const n = /* @__PURE__ */ new WeakMap();
34
34
  function e(r) {
@@ -36,11 +36,11 @@ function m(t) {
36
36
  return new Date(r);
37
37
  if (A(r))
38
38
  return new RegExp(r);
39
- if (d(r)) {
39
+ if (a(r)) {
40
40
  if (n.has(r))
41
41
  return n.get(r);
42
42
  let o = {};
43
- if (l(r)) {
43
+ if (g(r)) {
44
44
  o = [], n.set(r, o);
45
45
  for (let i = 0; i < r.length; i++)
46
46
  o[i] = e(r[i]);
@@ -55,23 +55,23 @@ function m(t) {
55
55
  }
56
56
  return e(t);
57
57
  }
58
- function p(t, n, e) {
59
- return l(t) ? x(t, n, e) : S(t, n, e);
58
+ function s(t, n, e) {
59
+ return g(t) ? S(t, n, e) : N(t, n, e);
60
60
  }
61
- function S(t, n, e) {
62
- const r = s(n, e);
61
+ function N(t, n, e) {
62
+ const r = c(n, e);
63
63
  return Object.keys(t).forEach((i) => {
64
- c(n[i]) ? r[i] = s(t[i], e) : r[i] = d(t[i]) && d(n[i]) ? p(t[i], n[i], e) : s(n[i], e);
64
+ u(n[i]) ? r[i] = c(t[i], e) : r[i] = a(t[i]) && a(n[i]) ? s(t[i], n[i], e) : c(n[i], e);
65
65
  }), r;
66
66
  }
67
- function x(t, n, e) {
68
- if (l(n)) {
69
- const r = s(n, e);
70
- return r.push(...s(t, e)), r;
67
+ function S(t, n, e) {
68
+ if (g(n)) {
69
+ const r = c(n, e);
70
+ return r.push(...c(t, e)), r;
71
71
  } else
72
- return s(t, e);
72
+ return c(t, e);
73
73
  }
74
- function s(t, n) {
74
+ function c(t, n) {
75
75
  const { clone: e = !0 } = n || {};
76
76
  return e ? m(t) : t;
77
77
  }
@@ -80,46 +80,46 @@ class b extends Error {
80
80
  super(n), this.name = "LntvowError";
81
81
  }
82
82
  }
83
- function N(t, n) {
83
+ function x(t, n) {
84
84
  throw new b(`[${t}] ${n}`);
85
85
  }
86
- function G(t, n) {
86
+ function V(t, n) {
87
87
  if (process.env.NODE_ENV !== "production") {
88
88
  const e = M(t) ? new b(`[${t}] ${n}`) : t;
89
89
  console.warn(e);
90
90
  }
91
91
  }
92
92
  function I(t, n) {
93
- const { decode: e } = p({ decode: !0 }, n || {}), r = {};
93
+ const { decode: e } = s({ decode: !0 }, n || {}), r = {};
94
94
  t.startsWith("?") && (t = t.slice(1)), t.includes("?") && (t = t.slice(t.indexOf("?") + 1));
95
95
  const o = t.split("&").filter(Boolean);
96
96
  for (const i of o) {
97
- const [f, u] = i.split("=");
98
- r[f] = e ? decodeURIComponent(u) : u;
97
+ const [f, d] = i.split("=");
98
+ r[f] = e ? decodeURIComponent(d) : d;
99
99
  }
100
100
  return r;
101
101
  }
102
102
  function w(t, n) {
103
- const { encode: e } = p({ encode: !0 }, n || {}), r = [];
103
+ const { encode: e } = s({ encode: !0 }, n || {}), r = [];
104
104
  for (const o in t) {
105
105
  const i = t[o];
106
106
  r.push(`${o}=${e ? encodeURIComponent(i) : i}`);
107
107
  }
108
108
  return r.join("&");
109
109
  }
110
- function P(t, n, e) {
111
- const r = p({ encode: !0 }, e || {}), o = w(n, r);
110
+ function R(t, n, e) {
111
+ const r = s({ encode: !0 }, e || {}), o = w(n, r);
112
112
  return t.includes("?") ? t.endsWith("?") || t.endsWith("&") ? `${t}${o}` : `${t}&${o}` : `${t}?${o}`;
113
113
  }
114
- const H = {
114
+ const X = {
115
115
  parse: I,
116
116
  stringify: w,
117
- appendQueryString: P
117
+ appendQueryString: R
118
118
  };
119
- function J(t, n = 500) {
119
+ function H(t, n = 500) {
120
120
  let e = null;
121
121
  return function(...r) {
122
- if (c(e))
122
+ if (u(e))
123
123
  return e = Date.now(), t.apply(this, r);
124
124
  {
125
125
  const o = Date.now();
@@ -128,7 +128,7 @@ function J(t, n = 500) {
128
128
  }
129
129
  };
130
130
  }
131
- function X(t) {
131
+ function J(t) {
132
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(
133
133
  t
134
134
  );
@@ -140,7 +140,7 @@ function k(t) {
140
140
  return /^[A-Z]+$/.test(t);
141
141
  }
142
142
  function tt(t) {
143
- return !c(t) && /^[a-z]+$/.test(t);
143
+ return !u(t) && /^[a-z]+$/.test(t);
144
144
  }
145
145
  function nt(t) {
146
146
  return /^\d+$/.test(t);
@@ -152,13 +152,13 @@ function rt(t) {
152
152
  return t === "";
153
153
  }
154
154
  function ot(t) {
155
- return !c(t) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
155
+ return !u(t) && /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
156
156
  }
157
157
  function it(t) {
158
- return !c(t) && /^[A-Za-z\u4E00-\u9FA5]+$/.test(t);
158
+ return !u(t) && /^[A-Za-z\u4E00-\u9FA5]+$/.test(t);
159
159
  }
160
160
  function st(t) {
161
- return !c(t) && /^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t);
161
+ return !u(t) && /^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t);
162
162
  }
163
163
  function ct(t) {
164
164
  return /^[\dA-Z_]+$/.test(t);
@@ -166,45 +166,45 @@ function ct(t) {
166
166
  function ut(t) {
167
167
  return /^[1-9]\d*$/.test(t);
168
168
  }
169
- function ft(t) {
169
+ function dt(t) {
170
170
  return /^\d+$/.test(t);
171
171
  }
172
- function dt(t) {
172
+ function ft(t) {
173
173
  return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t);
174
174
  }
175
- function O(t) {
176
- return l(t) ? t : [t];
175
+ function E(t) {
176
+ return g(t) ? t : [t];
177
177
  }
178
178
  function at(t, n) {
179
179
  const e = m(t);
180
- return O(n).forEach((o) => {
180
+ return E(n).forEach((o) => {
181
181
  $(e, o) && delete e[o];
182
182
  }), e;
183
183
  }
184
184
  function lt(t, n) {
185
185
  const e = {};
186
- return O(n).forEach((o) => {
186
+ return E(n).forEach((o) => {
187
187
  $(t, o) && (e[o] = t[o]);
188
188
  }), e;
189
189
  }
190
- function pt() {
190
+ function gt() {
191
191
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
192
192
  }
193
- function gt(t = 0, n = 1e6) {
193
+ function pt(t = 0, n = 1e9) {
194
194
  return Math.random() * (n - t) + t;
195
195
  }
196
- function ht(t = 0, n = 1e6) {
196
+ function ht(t = 0, n = Number.MAX_SAFE_INTEGER) {
197
197
  return Math.floor(Math.random() * (n - t + 1)) + Math.floor(t);
198
198
  }
199
199
  function $t(t, n = {}) {
200
- const { lowerCase: e = !0, upperCase: r = !0, number: o = !0 } = n;
201
- e || r || o || N("getRandomString", "lowerCase upperCase number 至少需要一个参数为true");
200
+ const { lowerCase: e, upperCase: r, number: o } = s({ lowerCase: !0, upperCase: !0, number: !0 }, n);
201
+ e || r || o || x("getRandomString", "lowerCase upperCase number 至少需要一个参数为true");
202
202
  let i = "";
203
203
  e && (i += "abcdefghijklmnopqrstuvwxyz"), r && (i += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), o && (i += "0123456789");
204
204
  let f = "";
205
- for (let u = 0; u < t; u++) {
206
- const E = Math.floor(Math.random() * i.length);
207
- f += i.charAt(E);
205
+ for (let d = 0; d < t; d++) {
206
+ const O = Math.floor(Math.random() * i.length);
207
+ f += i.charAt(O);
208
208
  }
209
209
  return f;
210
210
  }
@@ -217,90 +217,95 @@ function bt(t) {
217
217
  function wt(t) {
218
218
  return /^(0|[1-9]\d*)$/.test(t);
219
219
  }
220
- function Ot(t) {
220
+ function Et(t) {
221
221
  return /^-([1-9]\d*)$/.test(t);
222
222
  }
223
- function Et(t) {
223
+ function Ot(t) {
224
224
  return /^(0|-(0|[1-9]\d*))$/.test(t);
225
225
  }
226
- function yt(t, n) {
227
- return /^-?\d+(\.\d+)?$/.test(t);
226
+ function yt(t, n = {}) {
227
+ const { integer: e } = s({ integer: !0 }, n);
228
+ return e ? /^-?(0|[1-9]\d*)(\.\d+)?$/.test(t) : /^-?(0|[1-9]\d*)\.\d+$/.test(t);
228
229
  }
229
- function Ct(t) {
230
- return /^(0\.\d+|[1-9]\d*(\.\d+)?)$/.test(t);
230
+ function Ct(t, n = {}) {
231
+ const { integer: e } = s({ integer: !0 }, n);
232
+ return e ? /^[1-9]\d*\.?\d*|^0\.\d*[1-9]\d*$/.test(t) : /^[1-9]\d*\.\d*|^0\.\d*[1-9]\d*$/.test(t);
231
233
  }
232
- function At(t) {
233
- return /^-\d+(\.\d+)?$/.test(t);
234
+ function At(t, n = {}) {
235
+ const { integer: e } = s({ integer: !0 }, n);
236
+ return e ? /^-[1-9]\d*\.?\d*|^-0\.\d*[1-9]\d*$/.test(t) : /^-[1-9]\d*\.\d*|^-0\.\d*[1-9]\d*$/.test(t);
234
237
  }
235
- function Mt(t) {
236
- return /^\d+(\.\d+)?$/.test(t);
238
+ function Mt(t, n = {}) {
239
+ const { integer: e } = s({ integer: !0 }, n);
240
+ return e ? /^(0|[1-9]\d*)(\.\d+)?$/.test(t) : /^(0|[1-9]\d*)\.\d+$/.test(t);
237
241
  }
238
- function St(t) {
239
- return /^(-\d+(\.\d+)?$)|(0(\.0+)?)$/.test(t);
242
+ function Nt(t, n = {}) {
243
+ const { integer: e } = s({ integer: !0 }, n);
244
+ return e ? /^(-?0(\.0+)?|-(0|[1-9]\d*)(\.\d+)?)$/.test(t) : /^(-?0\.0+|-(0|[1-9]\d*)\.\d+)$/.test(t);
240
245
  }
241
246
  export {
242
- O as castArray,
243
- R as compose,
244
- j as composeRight,
245
- F as debounce,
246
- G as debugWarn,
247
+ E as castArray,
248
+ F as compose,
249
+ P as composeRight,
250
+ j as debounce,
251
+ V as debugWarn,
247
252
  m as deepClone,
248
- p as deepMerge,
249
- D as error,
253
+ s as deepMerge,
254
+ L as error,
250
255
  at as excludeProperties,
251
256
  lt as extractProperties,
252
- pt as getRandomColor,
253
- gt as getRandomFloat,
257
+ gt as getRandomColor,
258
+ pt as getRandomFloat,
254
259
  ht as getRandomInteger,
255
260
  $t as getRandomString,
256
- V as hasChanged,
261
+ Q as hasChanged,
257
262
  $ as hasOwn,
258
263
  Z as initLog,
259
- l as isArray,
260
- Q as isBoolean,
264
+ g as isArray,
265
+ G as isBoolean,
261
266
  C as isDate,
262
267
  K as isDef,
263
268
  rt as isEmptyString,
264
269
  yt as isFloat,
265
270
  h as isFunction,
266
271
  mt as isInteger,
267
- L as isMap,
272
+ T as isMap,
268
273
  At as isNegativeFloat,
269
- St as isNegativeFloatOrZero,
270
- Ot as isNegativeInteger,
271
- Et as isNegativeIntegerOrZero,
274
+ Nt as isNegativeFloatOrZero,
275
+ Et as isNegativeInteger,
276
+ Ot as isNegativeIntegerOrZero,
272
277
  B as isNull,
273
- T as isNumber,
274
- d as isObject,
278
+ _ as isNumber,
279
+ a as isObject,
275
280
  Ct as isPositiveFloat,
276
281
  Mt as isPositiveFloatOrZero,
277
282
  bt as isPositiveInteger,
278
283
  wt as isPositiveIntegerOrZero,
279
- _ as isPromise,
284
+ z as isPromise,
280
285
  A as isRegExp,
281
286
  W as isSet,
282
287
  M as isString,
283
- z as isSymbol,
284
- c as isUndef,
288
+ v as isSymbol,
289
+ u as isUndef,
285
290
  q as isUndefined,
286
- v as log,
291
+ U as log,
287
292
  y as objectToString,
288
- H as qs,
289
- J as throttle,
290
- N as throwError,
291
- a as toTypeString,
293
+ X as qs,
294
+ H as throttle,
295
+ x as throwError,
296
+ l as toTypeString,
292
297
  it as validatorChineseOrEnglish,
293
298
  ot as validatorChineseOrEnglishOrNumber,
294
299
  Y as validatorEmail,
295
300
  et as validatorLatitudeOrLongitude,
296
301
  tt as validatorLowerCase,
297
- X as validatorMobilePhone,
302
+ J as validatorMobilePhone,
298
303
  nt as validatorNumber,
299
- dt as validatorPositiveFloat,
304
+ ft as validatorPositiveFloat,
300
305
  ut as validatorPositiveInt,
301
- ft as validatorPositiveIntAndZero,
306
+ dt as validatorPositiveIntAndZero,
302
307
  k as validatorUpperCase,
303
308
  st as validatorUppercaseOrNumbersOrSpecial,
304
309
  ct as validatorUppercaseOrNumbersOrUnderline,
305
- U as warn
310
+ D as warn
306
311
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",