@lntvow/utils 2.1.17 → 2.2.1

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