@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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +50 -49
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
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
|
|
2
|
-
function
|
|
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
|
|
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
|
-
),
|
|
13
|
-
function
|
|
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,
|
|
17
|
-
function
|
|
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
|
-
|
|
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
|
|
44
|
-
return a(t) ?
|
|
43
|
+
function d(t, n, e) {
|
|
44
|
+
return a(t) ? C(t, n, e) : x(t, n, e);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function x(t, n, e) {
|
|
47
47
|
const o = s(n, e);
|
|
48
48
|
return Object.keys(t).forEach((r) => {
|
|
49
|
-
|
|
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
|
|
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 ?
|
|
57
|
+
return e ? O(t) : t;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
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
|
|
67
|
+
function F(t, n = 1e3) {
|
|
68
68
|
let e = null;
|
|
69
69
|
return function(...o) {
|
|
70
|
-
if (
|
|
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
|
|
85
|
-
c =
|
|
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
|
|
89
|
+
Date.now() - Number(n) >= 1e3 * c.time ? localStorage.removeItem(c.name) : new m();
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
|
|
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
|
|
95
|
-
initConsole:
|
|
96
|
-
showConsole:
|
|
95
|
+
const U = {
|
|
96
|
+
initConsole: D,
|
|
97
|
+
showConsole: E
|
|
97
98
|
};
|
|
98
99
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
106
|
-
|
|
106
|
+
_ as hasChanged,
|
|
107
|
+
j as hasOwn,
|
|
107
108
|
a as isArray,
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
b as isDate,
|
|
110
|
+
W as isDef,
|
|
110
111
|
g as isFunction,
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
A as isMap,
|
|
113
|
+
y as isNull,
|
|
113
114
|
f as isObject,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
126
|
+
I as warn
|
|
126
127
|
};
|