@lntvow/utils 2.2.4 → 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 O=Object.prototype.toString,l=t=>O.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=>l(t)==="[object Map]",U=t=>l(t)==="[object Set]",v=t=>l(t)==="[object Date]",w=t=>l(t)==="[object RegExp]",p=t=>typeof t=="function",j=t=>typeof t=="number",y=t=>typeof t=="string",L=t=>typeof t=="symbol",d=t=>t!==null&&typeof t=="object",D=t=>d(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",f=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(d(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 u(t,e,n){return f(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]=d(t[i])&&d(e[i])?u(t[i],e[i],n):c(e[i],n)}),r}function K(t,e,n){if(f(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}=u({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}=u({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=u({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 ut(t){return/^[1-9]\d*$/.test(t)}function at(t){return/^\d+$/.test(t)}function dt(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function $(t){return f(t)?t:[t]}function lt(t,e){const n=b(t);return $(e).forEach(o=>{h(n,o)&&delete n[o]}),n}function ft(t,e){const n={};return $(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 $t(t){return/^[1-9]\d*$/.test(t)}function Ot(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={}){const{integer:n}=u({integer:!0},e);return n?/^-?(0|[1-9]\d*)(\.\d+)?$/.test(t):/^-?(0|[1-9]\d*)\.\d+$/.test(t)}function Et(t){return/^[1-9]\d*\.?\d*|0\.\d*[1-9]\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=$;exports.compose=N;exports.composeRight=I;exports.debounce=F;exports.debugWarn=Q;exports.deepClone=b;exports.deepMerge=u;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=f;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=d;exports.isPositiveFloat=Et;exports.isPositiveFloatOrZero=St;exports.isPositiveInteger=$t;exports.isPositiveIntegerOrZero=Ot;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=O;exports.qs=H;exports.throttle=J;exports.throwError=P;exports.toTypeString=l;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=ut;exports.validatorPositiveIntAndZero=at;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
@@ -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(() => {
@@ -28,7 +28,7 @@ const U = (t, ...n) => {
28
28
  "padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
29
29
  e
30
30
  ), p && p(t, e);
31
- }, v = (...t) => console.warn(...t), D = (...t) => console.error(...t), L = (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 = (t) => typeof t == "number", M = (t) => typeof t == "string", z = (t) => typeof t == "symbol", a = (t) => t !== null && typeof t == "object", _ = (t) => a(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", g = Array.isArray, $ = (t, n) => Object.hasOwn(t, n), V = (t, n) => t !== n;
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) {
@@ -55,23 +55,23 @@ function m(t) {
55
55
  }
56
56
  return e(t);
57
57
  }
58
- function d(t, n, e) {
59
- return g(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] = a(t[i]) && a(n[i]) ? d(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) {
67
+ function S(t, n, e) {
68
68
  if (g(n)) {
69
- const r = s(n, e);
70
- return r.push(...s(t, e)), r;
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 } = d({ 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 } = d({ 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 = d({ 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);
@@ -172,39 +172,39 @@ function dt(t) {
172
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) {
175
+ function E(t) {
176
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
190
  function gt() {
191
191
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
192
192
  }
193
- function pt(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,85 +217,89 @@ 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
226
  function yt(t, n = {}) {
227
- const { integer: e } = d({ integer: !0 }, n);
227
+ const { integer: e } = s({ integer: !0 }, n);
228
228
  return e ? /^-?(0|[1-9]\d*)(\.\d+)?$/.test(t) : /^-?(0|[1-9]\d*)\.\d+$/.test(t);
229
229
  }
230
- function Ct(t) {
231
- return /^[1-9]\d*\.?\d*|0\.\d*[1-9]\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);
232
233
  }
233
- function At(t) {
234
- 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);
235
237
  }
236
- function Mt(t) {
237
- 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);
238
241
  }
239
- function St(t) {
240
- 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);
241
245
  }
242
246
  export {
243
- O as castArray,
244
- R as compose,
245
- j as composeRight,
246
- F as debounce,
247
- G as debugWarn,
247
+ E as castArray,
248
+ F as compose,
249
+ P as composeRight,
250
+ j as debounce,
251
+ V as debugWarn,
248
252
  m as deepClone,
249
- d as deepMerge,
250
- D as error,
253
+ s as deepMerge,
254
+ L as error,
251
255
  at as excludeProperties,
252
256
  lt as extractProperties,
253
257
  gt as getRandomColor,
254
258
  pt as getRandomFloat,
255
259
  ht as getRandomInteger,
256
260
  $t as getRandomString,
257
- V as hasChanged,
261
+ Q as hasChanged,
258
262
  $ as hasOwn,
259
263
  Z as initLog,
260
264
  g as isArray,
261
- Q as isBoolean,
265
+ G as isBoolean,
262
266
  C as isDate,
263
267
  K as isDef,
264
268
  rt as isEmptyString,
265
269
  yt as isFloat,
266
270
  h as isFunction,
267
271
  mt as isInteger,
268
- L as isMap,
272
+ T as isMap,
269
273
  At as isNegativeFloat,
270
- St as isNegativeFloatOrZero,
271
- Ot as isNegativeInteger,
272
- Et as isNegativeIntegerOrZero,
274
+ Nt as isNegativeFloatOrZero,
275
+ Et as isNegativeInteger,
276
+ Ot as isNegativeIntegerOrZero,
273
277
  B as isNull,
274
- T as isNumber,
278
+ _ as isNumber,
275
279
  a as isObject,
276
280
  Ct as isPositiveFloat,
277
281
  Mt as isPositiveFloatOrZero,
278
282
  bt as isPositiveInteger,
279
283
  wt as isPositiveIntegerOrZero,
280
- _ as isPromise,
284
+ z as isPromise,
281
285
  A as isRegExp,
282
286
  W as isSet,
283
287
  M as isString,
284
- z as isSymbol,
285
- c as isUndef,
288
+ v as isSymbol,
289
+ u as isUndef,
286
290
  q as isUndefined,
287
291
  U as log,
288
292
  y as objectToString,
289
- H as qs,
290
- J as throttle,
291
- N as throwError,
293
+ X as qs,
294
+ H as throttle,
295
+ x as throwError,
292
296
  l as toTypeString,
293
297
  it as validatorChineseOrEnglish,
294
298
  ot as validatorChineseOrEnglishOrNumber,
295
299
  Y as validatorEmail,
296
300
  et as validatorLatitudeOrLongitude,
297
301
  tt as validatorLowerCase,
298
- X as validatorMobilePhone,
302
+ J as validatorMobilePhone,
299
303
  nt as validatorNumber,
300
304
  ft as validatorPositiveFloat,
301
305
  ut as validatorPositiveInt,
@@ -303,5 +307,5 @@ export {
303
307
  k as validatorUpperCase,
304
308
  st as validatorUppercaseOrNumbersOrSpecial,
305
309
  ct as validatorUppercaseOrNumbersOrUnderline,
306
- v as warn
310
+ D as warn
307
311
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",