@lntvow/utils 2.2.2 → 2.2.3

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",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;
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;
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare function debugWarn(scope: string, message: string): void;
51
51
  * @param target 拷贝对象
52
52
  * @example deepClone({ name: 1, obj: { name: 1 }, arr: [1, 2, 3] }) => { name: 1, obj: { name: 1 }, arr: [1, 2, 3] }
53
53
  */
54
- export declare function deepClone<T = any>(target: T): T;
54
+ export declare function deepClone<T>(target: T): T;
55
55
 
56
56
  /**
57
57
  * @description 深度合并两对象
@@ -247,7 +247,7 @@ declare interface Options {
247
247
  * @description 是否开启深拷贝 默认开启
248
248
  * @default true
249
249
  */
250
- isDeepClone: boolean;
250
+ clone: boolean;
251
251
  }
252
252
 
253
253
  /**
package/dist/index.mjs CHANGED
@@ -28,7 +28,7 @@ const v = (t, ...n) => {
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]", 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;
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;
32
32
  function m(t) {
33
33
  const n = /* @__PURE__ */ new WeakMap();
34
34
  function e(r) {
@@ -72,7 +72,7 @@ function x(t, n, e) {
72
72
  return s(t, e);
73
73
  }
74
74
  function s(t, n) {
75
- const { isDeepClone: e = !0 } = n || {};
75
+ const { clone: e = !0 } = n || {};
76
76
  return e ? m(t) : t;
77
77
  }
78
78
  class b extends Error {
@@ -246,7 +246,7 @@ export {
246
246
  G as debugWarn,
247
247
  m as deepClone,
248
248
  p as deepMerge,
249
- U as error,
249
+ D as error,
250
250
  at as excludeProperties,
251
251
  lt as extractProperties,
252
252
  pt as getRandomColor,
@@ -302,5 +302,5 @@ export {
302
302
  k as validatorUpperCase,
303
303
  st as validatorUppercaseOrNumbersOrSpecial,
304
304
  ct as validatorUppercaseOrNumbersOrUnderline,
305
- D as warn
305
+ U as warn
306
306
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",