@lntvow/utils 1.7.4 → 1.7.6

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 m=require("vconsole");function O(){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 S=Object.prototype.toString,a=t=>S.call(t),D=(...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)),x=t=>console.warn(t),M=t=>console.error(t),E=t=>a(t)==="[object Map]",R=t=>a(t)==="[object Set]",b=t=>a(t)==="[object Date]",h=t=>a(t)==="[object RegExp]",p=t=>typeof t=="function",T=t=>typeof t=="string",N=t=>typeof t=="symbol",l=t=>t!==null&&typeof t=="object",A=t=>l(t)&&p(t.then)&&p(t.catch),w=t=>t==null,y=t=>t===null;function I(t){return t!=null}const f=Array.isArray,j=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),P=(t,n)=>t!==n;function C(t){const n=new WeakMap;function e(o){if(b(o))return new Date(o);if(h(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)j(o,r)&&(i[r]=e(o[r]));return i}else return o}return e(t)}function u(t,n,e){return f(t)?K(t,n,e):F(t,n,e)}function F(t,n,e){const o=c(n,e);return Object.keys(t).forEach(r=>{w(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 K(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?C(t):t}function L(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function U(t,n=1e3){let e=null;return function(...o){if(y(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 V(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 m}let d=0;function W(){d++,d>=s.count&&!localStorage.getItem(s.name)&&(localStorage.setItem(s.name,Date.now().toString()),new m)}const _={initConsole:V,showConsole:W};exports.debounce=L;exports.deepClone=C;exports.deepMerge=u;exports.error=M;exports.getRandomColor=O;exports.getRandomString=g;exports.hasChanged=P;exports.hasOwn=j;exports.isArray=f;exports.isDate=b;exports.isDef=I;exports.isFunction=p;exports.isMap=E;exports.isNull=y;exports.isObject=l;exports.isPromise=A;exports.isRegExp=h;exports.isSet=R;exports.isString=T;exports.isSymbol=N;exports.isUndef=w;exports.log=D;exports.nConsole=_;exports.objectToString=S;exports.throttle=U;exports.toTypeString=a;exports.warn=x;
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
@@ -1,25 +1,25 @@
1
- import u from "vconsole";
2
- function M() {
1
+ import m from "vconsole";
2
+ function R() {
3
3
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
4
4
  }
5
5
  function p(t) {
6
6
  return t > 10 ? p(10) + p(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
7
7
  }
8
- const d = Object.prototype.toString, l = (t) => d.call(t), R = (...t) => console.log(
8
+ const h = Object.prototype.toString, l = (t) => h.call(t), T = (...t) => console.log(
9
9
  `%c ${t[0]}: `,
10
10
  "padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
11
11
  t.slice(1)
12
- ), T = (t) => console.warn(t), I = (t) => console.error(t), N = (t) => l(t) === "[object Map]", A = (t) => l(t) === "[object Set]", h = (t) => l(t) === "[object Date]", b = (t) => l(t) === "[object RegExp]", g = (t) => typeof t == "function", K = (t) => typeof t == "string", L = (t) => typeof t == "symbol", f = (t) => t !== null && typeof t == "object", P = (t) => f(t) && g(t.then) && g(t.catch), w = (t) => t == null, S = (t) => t === null;
13
- function V(t) {
12
+ ), I = (t) => console.warn(t), N = (t) => console.error(t), A = (t) => l(t) === "[object Map]", K = (t) => l(t) === "[object Set]", b = (t) => l(t) === "[object Date]", w = (t) => l(t) === "[object RegExp]", g = (t) => typeof t == "function", L = (t) => typeof t == "string", P = (t) => typeof t == "symbol", f = (t) => t !== null && typeof t == "object", V = (t) => f(t) && g(t.then) && g(t.catch), S = (t) => t == null, y = (t) => t === null;
13
+ function W(t) {
14
14
  return t != null;
15
15
  }
16
- const a = Array.isArray, y = (t, n) => Object.prototype.hasOwnProperty.call(t, n), W = (t, n) => t !== n;
17
- function j(t) {
16
+ const a = Array.isArray, j = (t, n) => Object.prototype.hasOwnProperty.call(t, n), _ = (t, n) => t !== n;
17
+ function O(t) {
18
18
  const n = /* @__PURE__ */ new WeakMap();
19
19
  function e(o) {
20
- if (h(o))
21
- return new Date(o);
22
20
  if (b(o))
21
+ return new Date(o);
22
+ if (w(o))
23
23
  return new RegExp(o);
24
24
  if (f(o)) {
25
25
  if (n.has(o))
@@ -33,30 +33,30 @@ function j(t) {
33
33
  }
34
34
  n.set(o, i);
35
35
  for (const r in o)
36
- y(o, r) && (i[r] = e(o[r]));
36
+ j(o, r) && (i[r] = e(o[r]));
37
37
  return i;
38
38
  } else
39
39
  return o;
40
40
  }
41
41
  return e(t);
42
42
  }
43
- function m(t, n, e) {
44
- return a(t) ? x(t, n, e) : O(t, n, e);
43
+ function d(t, n, e) {
44
+ return a(t) ? C(t, n, e) : x(t, n, e);
45
45
  }
46
- function O(t, n, e) {
46
+ function x(t, n, e) {
47
47
  const o = s(n, e);
48
48
  return Object.keys(t).forEach((r) => {
49
- w(n[r]) ? o[r] = s(t[r], e) : o[r] = f(t[r]) && f(n[r]) ? m(t[r], n[r], e) : s(n[r], e);
49
+ S(n[r]) ? o[r] = s(t[r], e) : o[r] = f(t[r]) && f(n[r]) ? d(t[r], n[r], e) : s(n[r], e);
50
50
  }), o;
51
51
  }
52
- function x(t, n, e) {
52
+ function C(t, n, e) {
53
53
  return a(n) ? s(t, e).concat(s(n, e)) : s(n, e);
54
54
  }
55
55
  function s(t, n) {
56
56
  const { isDeepClone: e = !0 } = n || {};
57
- return e ? j(t) : t;
57
+ return e ? O(t) : t;
58
58
  }
59
- function _(t, n = 1e3) {
59
+ function $(t, n = 1e3) {
60
60
  let e = null;
61
61
  return function(...o) {
62
62
  e && clearTimeout(e), e = setTimeout(() => {
@@ -64,10 +64,10 @@ function _(t, n = 1e3) {
64
64
  }, n);
65
65
  };
66
66
  }
67
- function $(t, n = 1e3) {
67
+ function F(t, n = 1e3) {
68
68
  let e = null;
69
69
  return function(...o) {
70
- if (S(e))
70
+ if (y(e))
71
71
  return e = Date.now(), t.apply(this, ...o);
72
72
  {
73
73
  const i = Date.now();
@@ -81,46 +81,47 @@ let c = {
81
81
  time: 3600,
82
82
  count: 20
83
83
  };
84
- function C(t) {
85
- c = m(c, t);
84
+ function D(t) {
85
+ c = d(c, t || {});
86
86
  const n = localStorage.getItem(c.name);
87
87
  if (!n)
88
88
  return;
89
- Date.now() - Number(n) >= 1e3 * c.time ? localStorage.removeItem(c.name) : new u();
89
+ Date.now() - Number(n) >= 1e3 * c.time ? localStorage.removeItem(c.name) : new m();
90
90
  }
91
- function D() {
92
- c.count++, c.count >= 20 && !localStorage.getItem(c.name) && (localStorage.setItem(c.name, Date.now().toString()), new u());
91
+ let u = 0;
92
+ function E() {
93
+ u++, u >= c.count && !localStorage.getItem(c.name) && (localStorage.setItem(c.name, Date.now().toString()), new m());
93
94
  }
94
- const F = {
95
- initConsole: C,
96
- showConsole: D
95
+ const U = {
96
+ initConsole: D,
97
+ showConsole: E
97
98
  };
98
99
  export {
99
- _ as debounce,
100
- j as deepClone,
101
- m as deepMerge,
102
- I as error,
103
- M as getRandomColor,
100
+ $ as debounce,
101
+ O as deepClone,
102
+ d as deepMerge,
103
+ N as error,
104
+ R as getRandomColor,
104
105
  p as getRandomString,
105
- W as hasChanged,
106
- y as hasOwn,
106
+ _ as hasChanged,
107
+ j as hasOwn,
107
108
  a as isArray,
108
- h as isDate,
109
- V as isDef,
109
+ b as isDate,
110
+ W as isDef,
110
111
  g as isFunction,
111
- N as isMap,
112
- S as isNull,
112
+ A as isMap,
113
+ y as isNull,
113
114
  f as isObject,
114
- P as isPromise,
115
- b as isRegExp,
116
- A as isSet,
117
- K as isString,
118
- L as isSymbol,
119
- w as isUndef,
120
- R as log,
121
- F as nConsole,
122
- d as objectToString,
123
- $ as throttle,
115
+ V as isPromise,
116
+ w as isRegExp,
117
+ K as isSet,
118
+ L as isString,
119
+ P as isSymbol,
120
+ S as isUndef,
121
+ T as log,
122
+ U as nConsole,
123
+ h as objectToString,
124
+ F as throttle,
124
125
  l as toTypeString,
125
- T as warn
126
+ I as warn
126
127
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",