@lntvow/utils 1.7.13 → 1.8.0
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 +0 -34
- package/dist/index.mjs +85 -107
- package/package.json +3 -5
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
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
|
@@ -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 目标函数
|
package/dist/index.mjs
CHANGED
|
@@ -1,139 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
function R() {
|
|
1
|
+
function S() {
|
|
3
2
|
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
4
3
|
}
|
|
5
|
-
function
|
|
6
|
-
return
|
|
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
|
|
9
|
-
`%c ${
|
|
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
|
-
|
|
12
|
-
),
|
|
13
|
-
function
|
|
14
|
-
return
|
|
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,
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
function e
|
|
20
|
-
if (
|
|
21
|
-
return new Date(
|
|
22
|
-
if (
|
|
23
|
-
return new RegExp(
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
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(
|
|
29
|
-
c = [],
|
|
30
|
-
for (let r = 0; r <
|
|
31
|
-
c[r] = e
|
|
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
|
-
|
|
35
|
-
for (const r in
|
|
36
|
-
|
|
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
|
|
38
|
+
return e;
|
|
40
39
|
}
|
|
41
|
-
return
|
|
40
|
+
return o(n);
|
|
42
41
|
}
|
|
43
|
-
function
|
|
44
|
-
return u(
|
|
42
|
+
function w(n, t, o) {
|
|
43
|
+
return u(n) ? x(n, t, o) : m(n, t, o);
|
|
45
44
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return Object.keys(
|
|
49
|
-
|
|
50
|
-
}),
|
|
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
|
|
53
|
-
return u(
|
|
51
|
+
function x(n, t, o) {
|
|
52
|
+
return u(t) ? i(n, o).concat(i(t, o)) : i(t, o);
|
|
54
53
|
}
|
|
55
|
-
function
|
|
56
|
-
const { isDeepClone:
|
|
57
|
-
return
|
|
54
|
+
function i(n, t) {
|
|
55
|
+
const { isDeepClone: o = !0 } = t || {};
|
|
56
|
+
return o ? j(n) : n;
|
|
58
57
|
}
|
|
59
|
-
function $(
|
|
60
|
-
let
|
|
61
|
-
return function(...
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
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(
|
|
68
|
-
let
|
|
69
|
-
return function(...
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
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 -
|
|
75
|
-
return
|
|
73
|
+
if (c - o >= t)
|
|
74
|
+
return o = c, n.apply(this, ...e);
|
|
76
75
|
}
|
|
77
76
|
};
|
|
78
77
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
105
|
-
return
|
|
106
|
-
return
|
|
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
|
-
|
|
111
|
-
|
|
89
|
+
N as compose,
|
|
90
|
+
U as composeRight,
|
|
112
91
|
$ as debounce,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
138
|
-
|
|
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.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "工具库",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,16 +21,14 @@
|
|
|
21
21
|
"typescript": "^5.0.4",
|
|
22
22
|
"vite": "^4.4.4",
|
|
23
23
|
"vite-plugin-dts": "3.3.1",
|
|
24
|
-
"vitest": "^0.33.0"
|
|
24
|
+
"vitest": "^0.33.0",
|
|
25
|
+
"vconsole": "^3.15.1"
|
|
25
26
|
},
|
|
26
27
|
"config": {
|
|
27
28
|
"commitizen": {
|
|
28
29
|
"path": "node_modules/cz-conventional-changelog"
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"vconsole": "^3.15.1"
|
|
33
|
-
},
|
|
34
32
|
"scripts": {
|
|
35
33
|
"dev": "vite",
|
|
36
34
|
"test": "vitest",
|