@lntvow/utils 2.2.0 → 2.2.2

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