@lntvow/utils 1.8.0 → 1.8.1
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.mjs +60 -56
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function j(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function j(){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 p=Object.prototype.toString,f=t=>p.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]",l=t=>typeof t=="function",D=t=>typeof t=="string",C=t=>typeof t=="symbol",c=t=>t!==null&&typeof t=="object",E=t=>c(t)&&l(t.then)&&l(t.catch),h=t=>t==null,b=t=>t===null;function T(t){return t!=null}const u=Array.isArray,S=(t,e)=>Object.hasOwn(t,e),A=(t,e)=>t!==e;function m(t){const e=new WeakMap;function o(n){if(d(n))return new Date(n);if(a(n))return new RegExp(n);if(c(n)){if(e.has(n))return e.get(n);let i={};if(u(n)){i=[],e.set(n,i);for(let r=0;r<n.length;r++)i[r]=o(n[r]);return i}e.set(n,i);for(const r in n)S(n,r)&&(i[r]=o(n[r]));return i}else return n}return o(t)}function y(t,e,o){return u(t)?F(t,e,o):P(t,e,o)}function P(t,e,o){const n=s(e,o);return Object.keys(t).forEach(r=>{h(e[r])?n[r]=s(t[r],o):n[r]=c(t[r])&&c(e[r])?y(t[r],e[r],o):s(e[r],o)}),n}function F(t,e,o){if(u(e)){const n=s(e,o);return n.push(...s(t,o)),n}else return s(t,o)}function s(t,e){const{isDeepClone:o=!0}=e||{};return o?m(t):t}function K(t,e=1e3){let o=null;return function(...n){o&&clearTimeout(o),o=setTimeout(()=>{t.apply(this,...n)},e)}}function N(t,e=1e3){let o=null;return function(...n){if(b(o))return o=Date.now(),t.apply(this,...n);{const i=Date.now();if(i-o>=e)return o=i,t.apply(this,...n)}}}function U(...t){return t.reduce((e,o)=>function(...n){return o(e(...n))})}function $(...t){return t.reduce((e,o)=>function(...n){return e(o(...n))})}exports.compose=U;exports.composeRight=$;exports.debounce=K;exports.deepClone=m;exports.deepMerge=y;exports.error=M;exports.getRandomColor=j;exports.getRandomString=g;exports.hasChanged=A;exports.hasOwn=S;exports.isArray=u;exports.isDate=d;exports.isDef=T;exports.isFunction=l;exports.isMap=O;exports.isNull=b;exports.isObject=c;exports.isPromise=E;exports.isRegExp=a;exports.isSet=R;exports.isString=D;exports.isSymbol=C;exports.isUndef=h;exports.log=w;exports.objectToString=p;exports.throttle=N;exports.toTypeString=f;exports.warn=x;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m() {
|
|
2
2
|
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
3
3
|
}
|
|
4
4
|
function p(n) {
|
|
@@ -8,94 +8,98 @@ const d = Object.prototype.toString, f = (n) => d.call(n), D = (...n) => console
|
|
|
8
8
|
`%c ${n[0]}: `,
|
|
9
9
|
"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
|
|
10
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]",
|
|
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]", h = (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), a = (n) => n == null, b = (n) => n === null;
|
|
12
12
|
function K(n) {
|
|
13
13
|
return n != null;
|
|
14
14
|
}
|
|
15
|
-
const u = Array.isArray,
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
function o(
|
|
19
|
-
if (g(
|
|
20
|
-
return new Date(
|
|
21
|
-
if (
|
|
22
|
-
return new RegExp(
|
|
23
|
-
if (s(
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
15
|
+
const u = Array.isArray, j = (n, e) => Object.hasOwn(n, e), $ = (n, e) => n !== e;
|
|
16
|
+
function w(n) {
|
|
17
|
+
const e = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
function o(t) {
|
|
19
|
+
if (g(t))
|
|
20
|
+
return new Date(t);
|
|
21
|
+
if (h(t))
|
|
22
|
+
return new RegExp(t);
|
|
23
|
+
if (s(t)) {
|
|
24
|
+
if (e.has(t))
|
|
25
|
+
return e.get(t);
|
|
26
26
|
let c = {};
|
|
27
|
-
if (u(
|
|
28
|
-
c = [],
|
|
29
|
-
for (let r = 0; r <
|
|
30
|
-
c[r] = o(
|
|
27
|
+
if (u(t)) {
|
|
28
|
+
c = [], e.set(t, c);
|
|
29
|
+
for (let r = 0; r < t.length; r++)
|
|
30
|
+
c[r] = o(t[r]);
|
|
31
31
|
return c;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
for (const r in
|
|
35
|
-
|
|
33
|
+
e.set(t, c);
|
|
34
|
+
for (const r in t)
|
|
35
|
+
j(t, r) && (c[r] = o(t[r]));
|
|
36
36
|
return c;
|
|
37
37
|
} else
|
|
38
|
-
return
|
|
38
|
+
return t;
|
|
39
39
|
}
|
|
40
40
|
return o(n);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return u(n) ?
|
|
42
|
+
function y(n, e, o) {
|
|
43
|
+
return u(n) ? S(n, e, o) : x(n, e, o);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
45
|
+
function x(n, e, o) {
|
|
46
|
+
const t = i(e, o);
|
|
47
47
|
return Object.keys(n).forEach((r) => {
|
|
48
|
-
|
|
49
|
-
}),
|
|
48
|
+
a(e[r]) ? t[r] = i(n[r], o) : t[r] = s(n[r]) && s(e[r]) ? y(n[r], e[r], o) : i(e[r], o);
|
|
49
|
+
}), t;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
51
|
+
function S(n, e, o) {
|
|
52
|
+
if (u(e)) {
|
|
53
|
+
const t = i(e, o);
|
|
54
|
+
return t.push(...i(n, o)), t;
|
|
55
|
+
} else
|
|
56
|
+
return i(n, o);
|
|
53
57
|
}
|
|
54
|
-
function i(n,
|
|
55
|
-
const { isDeepClone: o = !0 } =
|
|
56
|
-
return o ?
|
|
58
|
+
function i(n, e) {
|
|
59
|
+
const { isDeepClone: o = !0 } = e || {};
|
|
60
|
+
return o ? w(n) : n;
|
|
57
61
|
}
|
|
58
|
-
function
|
|
62
|
+
function F(n, e = 1e3) {
|
|
59
63
|
let o = null;
|
|
60
|
-
return function(...
|
|
64
|
+
return function(...t) {
|
|
61
65
|
o && clearTimeout(o), o = setTimeout(() => {
|
|
62
|
-
n.apply(this, ...
|
|
63
|
-
},
|
|
66
|
+
n.apply(this, ...t);
|
|
67
|
+
}, e);
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
|
-
function
|
|
70
|
+
function N(n, e = 1e3) {
|
|
67
71
|
let o = null;
|
|
68
|
-
return function(...
|
|
72
|
+
return function(...t) {
|
|
69
73
|
if (b(o))
|
|
70
|
-
return o = Date.now(), n.apply(this, ...
|
|
74
|
+
return o = Date.now(), n.apply(this, ...t);
|
|
71
75
|
{
|
|
72
76
|
const c = Date.now();
|
|
73
|
-
if (c - o >=
|
|
74
|
-
return o = c, n.apply(this, ...
|
|
77
|
+
if (c - o >= e)
|
|
78
|
+
return o = c, n.apply(this, ...t);
|
|
75
79
|
}
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
|
-
function
|
|
79
|
-
return n.reduce((
|
|
80
|
-
return o(
|
|
82
|
+
function P(...n) {
|
|
83
|
+
return n.reduce((e, o) => function(...t) {
|
|
84
|
+
return o(e(...t));
|
|
81
85
|
});
|
|
82
86
|
}
|
|
83
87
|
function U(...n) {
|
|
84
|
-
return n.reduce((
|
|
85
|
-
return
|
|
88
|
+
return n.reduce((e, o) => function(...t) {
|
|
89
|
+
return e(o(...t));
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
export {
|
|
89
|
-
|
|
93
|
+
P as compose,
|
|
90
94
|
U as composeRight,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
F as debounce,
|
|
96
|
+
w as deepClone,
|
|
97
|
+
y as deepMerge,
|
|
94
98
|
O as error,
|
|
95
|
-
|
|
99
|
+
m as getRandomColor,
|
|
96
100
|
p as getRandomString,
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
$ as hasChanged,
|
|
102
|
+
j as hasOwn,
|
|
99
103
|
u as isArray,
|
|
100
104
|
g as isDate,
|
|
101
105
|
K as isDef,
|
|
@@ -104,14 +108,14 @@ export {
|
|
|
104
108
|
b as isNull,
|
|
105
109
|
s as isObject,
|
|
106
110
|
A as isPromise,
|
|
107
|
-
|
|
111
|
+
h as isRegExp,
|
|
108
112
|
R as isSet,
|
|
109
113
|
C as isString,
|
|
110
114
|
T as isSymbol,
|
|
111
|
-
|
|
115
|
+
a as isUndef,
|
|
112
116
|
D as log,
|
|
113
117
|
d as objectToString,
|
|
114
|
-
|
|
118
|
+
N as throttle,
|
|
115
119
|
f as toTypeString,
|
|
116
120
|
M as warn
|
|
117
121
|
};
|