@lntvow/utils 1.7.12 → 1.7.14

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 m=require("vconsole");function O(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function u(t){return t>10?u(10)+u(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const S=Object.prototype.toString,f=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),R=t=>f(t)==="[object Map]",E=t=>f(t)==="[object Set]",h=t=>f(t)==="[object Date]",b=t=>f(t)==="[object RegExp]",g=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)&&g(t.then)&&g(t.catch),w=t=>t==null,y=t=>t===null;function I(t){return t!=null}const a=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(h(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(a(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 p(t,n,e){return a(t)?K(t,n,e):F(t,n,e)}function F(t,n,e){const o=s(n,e);return Object.keys(t).forEach(r=>{w(n[r])?o[r]=s(t[r],e):o[r]=l(t[r])&&l(n[r])?p(t[r],n[r],e):s(n[r],e)}),o}function K(t,n,e){return a(n)?s(t,e).concat(s(n,e)):s(n,e)}function s(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 c={name:"LNTVOW_CONSOLE",time:3600,count:20};function V(t){c=p(c,t||{});const n=localStorage.getItem(c.name);if(!n)return;Date.now()-Number(n)>=1e3*c.time?localStorage.removeItem(c.name):new m}let d=0;function W(){d++,d>=c.count&&!localStorage.getItem(c.name)&&(localStorage.setItem(c.name,Date.now().toString()),new m)}const _={initConsole:V,showConsole:W};function $(...t){return t.reduce((n,e)=>function(...o){return e(n(...o))})}function q(...t){return t.reduce((n,e)=>function(...o){return n(e(...o))})}exports.compose=$;exports.composeRight=q;exports.debounce=L;exports.deepClone=C;exports.deepMerge=p;exports.error=M;exports.getRandomColor=O;exports.getRandomString=u;exports.hasChanged=P;exports.hasOwn=j;exports.isArray=a;exports.isDate=h;exports.isDef=I;exports.isFunction=g;exports.isMap=R;exports.isNull=y;exports.isObject=l;exports.isPromise=A;exports.isRegExp=b;exports.isSet=E;exports.isString=T;exports.isSymbol=N;exports.isUndef=w;exports.log=D;exports.nConsole=_;exports.objectToString=S;exports.throttle=U;exports.toTypeString=f;exports.warn=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function j(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function p(t){return t>10?p(10)+p(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const l=Object.prototype.toString,f=t=>l.call(t),w=(...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),O=t=>f(t)==="[object Map]",R=t=>f(t)==="[object Set]",d=t=>f(t)==="[object Date]",a=t=>f(t)==="[object RegExp]",g=t=>typeof t=="function",D=t=>typeof t=="string",C=t=>typeof t=="symbol",s=t=>t!==null&&typeof t=="object",E=t=>s(t)&&g(t.then)&&g(t.catch),h=t=>t==null,b=t=>t===null;function T(t){return t!=null}const u=Array.isArray,y=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),A=(t,n)=>t!==n;function S(t){const n=new WeakMap;function e(o){if(d(o))return new Date(o);if(a(o))return new RegExp(o);if(s(o)){if(n.has(o))return n.get(o);let i={};if(u(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 m(t,n,e){return u(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]=s(t[r])&&s(n[r])?m(t[r],n[r],e):c(n[r],e)}),o}function F(t,n,e){return u(n)?c(t,e).concat(c(n,e)):c(n,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?S(t):t}function K(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function N(t,n=1e3){let e=null;return function(...o){if(b(e))return e=Date.now(),t.apply(this,...o);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,...o)}}}function U(...t){return t.reduce((n,e)=>function(...o){return e(n(...o))})}function $(...t){return t.reduce((n,e)=>function(...o){return n(e(...o))})}exports.compose=U;exports.composeRight=$;exports.debounce=K;exports.deepClone=S;exports.deepMerge=m;exports.error=M;exports.getRandomColor=j;exports.getRandomString=p;exports.hasChanged=A;exports.hasOwn=y;exports.isArray=u;exports.isDate=d;exports.isDef=T;exports.isFunction=g;exports.isMap=O;exports.isNull=b;exports.isObject=s;exports.isPromise=E;exports.isRegExp=a;exports.isSet=R;exports.isString=D;exports.isSymbol=C;exports.isUndef=h;exports.log=w;exports.objectToString=l;exports.throttle=N;exports.toTypeString=f;exports.warn=x;
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ export declare function deepClone<T = any>(target: T): T;
38
38
  */
39
39
  export declare function deepMerge(template: AnyObj, source: AnyObj, options?: Options): any;
40
40
 
41
- export declare const error: (msg: string) => void;
41
+ export declare const error: (...arg: unknown[]) => void;
42
42
 
43
43
  /**
44
44
  * @description 获取随机颜色
@@ -61,30 +61,6 @@ export declare const hasChanged: (oldValue: unknown, newValue: unknown) => boole
61
61
 
62
62
  export declare const hasOwn: <T extends object, U extends keyof T>(target: T, key: U) => boolean;
63
63
 
64
- /**
65
- * @description 初始化
66
- * @param options 初始化配置
67
- */
68
- declare function initConsole(options?: InitConsoleOptions): void;
69
-
70
- declare interface InitConsoleOptions {
71
- /**
72
- * @description 缓存的key
73
- * @default LNTVOW_CONSOLE
74
- */
75
- name?: string;
76
- /**
77
- * @description 显示console的时间 单位s
78
- * @default 3600 一个小时
79
- */
80
- time?: number;
81
- /**
82
- * @description 显示console的事件触发次数
83
- * @default 20
84
- */
85
- count?: number;
86
- }
87
-
88
64
  export declare const isArray: (arg: any) => arg is any[];
89
65
 
90
66
  export declare const isDate: (val: unknown) => val is Date;
@@ -113,11 +89,6 @@ export declare const isUndef: (val: unknown) => val is null | undefined;
113
89
 
114
90
  export declare const log: (...arg: unknown[]) => void;
115
91
 
116
- export declare const nConsole: {
117
- initConsole: typeof initConsole;
118
- showConsole: typeof showConsole;
119
- };
120
-
121
92
  export declare const objectToString: () => string;
122
93
 
123
94
  declare interface Options {
@@ -128,11 +99,6 @@ declare interface Options {
128
99
  isDeepClone: boolean;
129
100
  }
130
101
 
131
- /**
132
- * @description 触发显示事件
133
- */
134
- declare function showConsole(): void;
135
-
136
102
  /**
137
103
  * @description 节流函数
138
104
  * @param target 目标函数
@@ -143,6 +109,6 @@ export declare function throttle(target: Function, wait?: number): (...args: any
143
109
 
144
110
  export declare const toTypeString: (value: unknown) => string;
145
111
 
146
- export declare const warn: (msg: string) => void;
112
+ export declare const warn: (...arg: unknown[]) => void;
147
113
 
148
114
  export { }
package/dist/index.mjs CHANGED
@@ -1,139 +1,117 @@
1
- import m from "vconsole";
2
- function R() {
1
+ function S() {
3
2
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
4
3
  }
5
- function a(t) {
6
- return t > 10 ? a(10) + a(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
4
+ function p(n) {
5
+ return n > 10 ? p(10) + p(n - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, n + 2);
7
6
  }
8
- const h = Object.prototype.toString, l = (t) => h.call(t), T = (...t) => console.log(
9
- `%c ${t[0]}: `,
7
+ const d = Object.prototype.toString, f = (n) => d.call(n), D = (...n) => console.log(
8
+ `%c ${n[0]}: `,
10
9
  "padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
11
- t.slice(1)
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]", p = (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) && p(t.then) && p(t.catch), S = (t) => t == null, y = (t) => t === null;
13
- function W(t) {
14
- return t != null;
10
+ n.slice(1)
11
+ ), M = (...n) => console.warn(...n), O = (...n) => console.error(...n), E = (n) => f(n) === "[object Map]", R = (n) => f(n) === "[object Set]", g = (n) => f(n) === "[object Date]", a = (n) => f(n) === "[object RegExp]", l = (n) => typeof n == "function", C = (n) => typeof n == "string", T = (n) => typeof n == "symbol", s = (n) => n !== null && typeof n == "object", A = (n) => s(n) && l(n.then) && l(n.catch), h = (n) => n == null, b = (n) => n === null;
12
+ function K(n) {
13
+ return n != null;
15
14
  }
16
- const u = Array.isArray, j = (t, n) => Object.prototype.hasOwnProperty.call(t, n), _ = (t, n) => t !== n;
17
- function O(t) {
18
- const n = /* @__PURE__ */ new WeakMap();
19
- function e(o) {
20
- if (b(o))
21
- return new Date(o);
22
- if (w(o))
23
- return new RegExp(o);
24
- if (f(o)) {
25
- if (n.has(o))
26
- return n.get(o);
15
+ const u = Array.isArray, y = (n, t) => Object.prototype.hasOwnProperty.call(n, t), P = (n, t) => n !== t;
16
+ function j(n) {
17
+ const t = /* @__PURE__ */ new WeakMap();
18
+ function o(e) {
19
+ if (g(e))
20
+ return new Date(e);
21
+ if (a(e))
22
+ return new RegExp(e);
23
+ if (s(e)) {
24
+ if (t.has(e))
25
+ return t.get(e);
27
26
  let c = {};
28
- if (u(o)) {
29
- c = [], n.set(o, c);
30
- for (let r = 0; r < o.length; r++)
31
- c[r] = e(o[r]);
27
+ if (u(e)) {
28
+ c = [], t.set(e, c);
29
+ for (let r = 0; r < e.length; r++)
30
+ c[r] = o(e[r]);
32
31
  return c;
33
32
  }
34
- n.set(o, c);
35
- for (const r in o)
36
- j(o, r) && (c[r] = e(o[r]));
33
+ t.set(e, c);
34
+ for (const r in e)
35
+ y(e, r) && (c[r] = o(e[r]));
37
36
  return c;
38
37
  } else
39
- return o;
38
+ return e;
40
39
  }
41
- return e(t);
40
+ return o(n);
42
41
  }
43
- function d(t, n, e) {
44
- return u(t) ? C(t, n, e) : x(t, n, e);
42
+ function w(n, t, o) {
43
+ return u(n) ? x(n, t, o) : m(n, t, o);
45
44
  }
46
- function x(t, n, e) {
47
- const o = s(n, e);
48
- return Object.keys(t).forEach((r) => {
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
- }), o;
45
+ function m(n, t, o) {
46
+ const e = i(t, o);
47
+ return Object.keys(n).forEach((r) => {
48
+ h(t[r]) ? e[r] = i(n[r], o) : e[r] = s(n[r]) && s(t[r]) ? w(n[r], t[r], o) : i(t[r], o);
49
+ }), e;
51
50
  }
52
- function C(t, n, e) {
53
- return u(n) ? s(t, e).concat(s(n, e)) : s(n, e);
51
+ function x(n, t, o) {
52
+ return u(t) ? i(n, o).concat(i(t, o)) : i(t, o);
54
53
  }
55
- function s(t, n) {
56
- const { isDeepClone: e = !0 } = n || {};
57
- return e ? O(t) : t;
54
+ function i(n, t) {
55
+ const { isDeepClone: o = !0 } = t || {};
56
+ return o ? j(n) : n;
58
57
  }
59
- function $(t, n = 1e3) {
60
- let e = null;
61
- return function(...o) {
62
- e && clearTimeout(e), e = setTimeout(() => {
63
- t.apply(this, ...o);
64
- }, n);
58
+ function $(n, t = 1e3) {
59
+ let o = null;
60
+ return function(...e) {
61
+ o && clearTimeout(o), o = setTimeout(() => {
62
+ n.apply(this, ...e);
63
+ }, t);
65
64
  };
66
65
  }
67
- function F(t, n = 1e3) {
68
- let e = null;
69
- return function(...o) {
70
- if (y(e))
71
- return e = Date.now(), t.apply(this, ...o);
66
+ function F(n, t = 1e3) {
67
+ let o = null;
68
+ return function(...e) {
69
+ if (b(o))
70
+ return o = Date.now(), n.apply(this, ...e);
72
71
  {
73
72
  const c = Date.now();
74
- if (c - e >= n)
75
- return e = c, t.apply(this, ...o);
73
+ if (c - o >= t)
74
+ return o = c, n.apply(this, ...e);
76
75
  }
77
76
  };
78
77
  }
79
- let i = {
80
- name: "LNTVOW_CONSOLE",
81
- time: 3600,
82
- count: 20
83
- };
84
- function D(t) {
85
- i = d(i, t || {});
86
- const n = localStorage.getItem(i.name);
87
- if (!n)
88
- return;
89
- Date.now() - Number(n) >= 1e3 * i.time ? localStorage.removeItem(i.name) : new m();
90
- }
91
- let g = 0;
92
- function E() {
93
- g++, g >= i.count && !localStorage.getItem(i.name) && (localStorage.setItem(i.name, Date.now().toString()), new m());
94
- }
95
- const U = {
96
- initConsole: D,
97
- showConsole: E
98
- };
99
- function q(...t) {
100
- return t.reduce((n, e) => function(...o) {
101
- return e(n(...o));
78
+ function N(...n) {
79
+ return n.reduce((t, o) => function(...e) {
80
+ return o(t(...e));
102
81
  });
103
82
  }
104
- function z(...t) {
105
- return t.reduce((n, e) => function(...o) {
106
- return n(e(...o));
83
+ function U(...n) {
84
+ return n.reduce((t, o) => function(...e) {
85
+ return t(o(...e));
107
86
  });
108
87
  }
109
88
  export {
110
- q as compose,
111
- z as composeRight,
89
+ N as compose,
90
+ U as composeRight,
112
91
  $ as debounce,
113
- O as deepClone,
114
- d as deepMerge,
115
- N as error,
116
- R as getRandomColor,
117
- a as getRandomString,
118
- _ as hasChanged,
119
- j as hasOwn,
92
+ j as deepClone,
93
+ w as deepMerge,
94
+ O as error,
95
+ S as getRandomColor,
96
+ p as getRandomString,
97
+ P as hasChanged,
98
+ y as hasOwn,
120
99
  u as isArray,
121
- b as isDate,
122
- W as isDef,
123
- p as isFunction,
124
- A as isMap,
125
- y as isNull,
126
- f as isObject,
127
- V as isPromise,
128
- w as isRegExp,
129
- K as isSet,
130
- L as isString,
131
- P as isSymbol,
132
- S as isUndef,
133
- T as log,
134
- U as nConsole,
135
- h as objectToString,
100
+ g as isDate,
101
+ K as isDef,
102
+ l as isFunction,
103
+ E as isMap,
104
+ b as isNull,
105
+ s as isObject,
106
+ A as isPromise,
107
+ a as isRegExp,
108
+ R as isSet,
109
+ C as isString,
110
+ T as isSymbol,
111
+ h as isUndef,
112
+ D as log,
113
+ d as objectToString,
136
114
  F as throttle,
137
- l as toTypeString,
138
- I as warn
115
+ f as toTypeString,
116
+ M as warn
139
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.7.12",
3
+ "version": "1.7.14",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",