@lntvow/utils 1.7.4 → 1.7.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"});const d=require("vconsole");function C(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function g(t){return t>10?g(10)+g(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const m=Object.prototype.toString,a=t=>m.call(t),O=(...t)=>console.log(`%c ${t[0]}: `,"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",t.slice(1)),D=t=>console.warn(t),x=t=>console.error(t),M=t=>a(t)==="[object Map]",E=t=>a(t)==="[object Set]",S=t=>a(t)==="[object Date]",b=t=>a(t)==="[object RegExp]",p=t=>typeof t=="function",R=t=>typeof t=="string",T=t=>typeof t=="symbol",l=t=>t!==null&&typeof t=="object",N=t=>l(t)&&p(t.then)&&p(t.catch),h=t=>t==null,w=t=>t===null;function A(t){return t!=null}const f=Array.isArray,y=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),I=(t,n)=>t!==n;function j(t){const n=new WeakMap;function e(o){if(S(o))return new Date(o);if(b(o))return new RegExp(o);if(l(o)){if(n.has(o))return n.get(o);let i={};if(f(o)){i=[],n.set(o,i);for(let r=0;r<o.length;r++)i[r]=e(o[r]);return i}n.set(o,i);for(const r in o)y(o,r)&&(i[r]=e(o[r]));return i}else return o}return e(t)}function u(t,n,e){return f(t)?F(t,n,e):P(t,n,e)}function P(t,n,e){const o=c(n,e);return Object.keys(t).forEach(r=>{h(n[r])?o[r]=c(t[r],e):o[r]=l(t[r])&&l(n[r])?u(t[r],n[r],e):c(n[r],e)}),o}function F(t,n,e){return f(n)?c(t,e).concat(c(n,e)):c(n,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?j(t):t}function K(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function L(t,n=1e3){let e=null;return function(...o){if(w(e))return e=Date.now(),t.apply(this,...o);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,...o)}}}let s={name:"LNTVOW_CONSOLE",time:3600,count:20};function U(t){s=u(s,t);const n=localStorage.getItem(s.name);if(!n)return;Date.now()-Number(n)>=1e3*s.time?localStorage.removeItem(s.name):new d}function V(){s.count++,s.count>=20&&!localStorage.getItem(s.name)&&(localStorage.setItem(s.name,Date.now().toString()),new d)}const W={initConsole:U,showConsole:V};exports.debounce=K;exports.deepClone=j;exports.deepMerge=u;exports.error=x;exports.getRandomColor=C;exports.getRandomString=g;exports.hasChanged=I;exports.hasOwn=y;exports.isArray=f;exports.isDate=S;exports.isDef=A;exports.isFunction=p;exports.isMap=M;exports.isNull=w;exports.isObject=l;exports.isPromise=N;exports.isRegExp=b;exports.isSet=E;exports.isString=R;exports.isSymbol=T;exports.isUndef=h;exports.log=O;exports.nConsole=W;exports.objectToString=m;exports.throttle=L;exports.toTypeString=a;exports.warn=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vconsole");function C(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function g(t){return t>10?g(10)+g(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const m=Object.prototype.toString,a=t=>m.call(t),O=(...t)=>console.log(`%c ${t[0]}: `,"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",t.slice(1)),D=t=>console.warn(t),x=t=>console.error(t),M=t=>a(t)==="[object Map]",E=t=>a(t)==="[object Set]",S=t=>a(t)==="[object Date]",b=t=>a(t)==="[object RegExp]",p=t=>typeof t=="function",R=t=>typeof t=="string",T=t=>typeof t=="symbol",l=t=>t!==null&&typeof t=="object",N=t=>l(t)&&p(t.then)&&p(t.catch),h=t=>t==null,w=t=>t===null;function A(t){return t!=null}const f=Array.isArray,y=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),I=(t,n)=>t!==n;function j(t){const n=new WeakMap;function e(o){if(S(o))return new Date(o);if(b(o))return new RegExp(o);if(l(o)){if(n.has(o))return n.get(o);let i={};if(f(o)){i=[],n.set(o,i);for(let r=0;r<o.length;r++)i[r]=e(o[r]);return i}n.set(o,i);for(const r in o)y(o,r)&&(i[r]=e(o[r]));return i}else return o}return e(t)}function u(t,n,e){return f(t)?F(t,n,e):P(t,n,e)}function P(t,n,e){const o=c(n,e);return Object.keys(t).forEach(r=>{h(n[r])?o[r]=c(t[r],e):o[r]=l(t[r])&&l(n[r])?u(t[r],n[r],e):c(n[r],e)}),o}function F(t,n,e){return f(n)?c(t,e).concat(c(n,e)):c(n,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?j(t):t}function K(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function L(t,n=1e3){let e=null;return function(...o){if(w(e))return e=Date.now(),t.apply(this,...o);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,...o)}}}let s={name:"LNTVOW_CONSOLE",time:3600,count:20};function U(t){s=u(s,t||{});const n=localStorage.getItem(s.name);if(!n)return;Date.now()-Number(n)>=1e3*s.time?localStorage.removeItem(s.name):new d}function V(){s.count++,s.count>=20&&!localStorage.getItem(s.name)&&(localStorage.setItem(s.name,Date.now().toString()),new d)}const W={initConsole:U,showConsole:V};exports.debounce=K;exports.deepClone=j;exports.deepMerge=u;exports.error=x;exports.getRandomColor=C;exports.getRandomString=g;exports.hasChanged=I;exports.hasOwn=y;exports.isArray=f;exports.isDate=S;exports.isDef=A;exports.isFunction=p;exports.isMap=M;exports.isNull=w;exports.isObject=l;exports.isPromise=N;exports.isRegExp=b;exports.isSet=E;exports.isString=R;exports.isSymbol=T;exports.isUndef=h;exports.log=O;exports.nConsole=W;exports.objectToString=m;exports.throttle=L;exports.toTypeString=a;exports.warn=D;
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare const hasOwn: <T extends object, U extends keyof T>(target: T, ke
51
51
  * @description 初始化
52
52
  * @param options 初始化配置
53
53
  */
54
- declare function initConsole(options: InitConsoleOptions): void;
54
+ declare function initConsole(options?: InitConsoleOptions): void;
55
55
 
56
56
  declare interface InitConsoleOptions {
57
57
  /**
package/dist/index.mjs CHANGED
@@ -82,7 +82,7 @@ let c = {
82
82
  count: 20
83
83
  };
84
84
  function C(t) {
85
- c = m(c, t);
85
+ c = m(c, t || {});
86
86
  const n = localStorage.getItem(c.name);
87
87
  if (!n)
88
88
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",